Script stopped working - flummoxed

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

Illuminata Photo

Script stopped working - flummoxed

Post by Illuminata Photo »

Earlier this month, I crafted a modest script to help me do some 3D rendering. I'm not a coder at heart, but have written a bit of it in my life. I had to go back and refresh my JS skills. My script worked beautifully the first and only time that I ran for real work (it did take me several days to get the script to function the way that I wanted; typical debugging). Basically, once my model is open, my script is to take some camera position input data, along with the number of render iterations (i) and the amount of camera shift on the x-axis (x), and then render the composition "i" number of times, each time shifting it by "x" on the x-axis.

Over the past several days, I've created a new 3D model that I want to render. When I try to run my script now, though, it just doesn't work. I create the number of iterations that I want, but my "x" position is static - not shifting as intended. I've spent most of the past day and more trying to figure out what's going on, but it's just not jumping out at me. My "feeling" is that my function is "overextended," in that it also may include my loop, but I'm not figuring out how to separate them.

I'm using PS CC 2014 on a Mac - don't know what else to tell you to assist...

Any thoughts???

Code: Select all
//This is the starting point for my 3D rendering script.  First created January, 2014 by Tim Mulholland/Illuminata Photo; Fitchburg, Wisconsin; tim@timmulholland.com
//The purpose of this script is to generate 3D renderings of my RVSP project files and save them, so that I can do other things while this is chugging along.
//The first part I wrote; the second part I captured via ScriptingListener.   tsm, 10 Jan 2015

// These first three variables ask the use for pertinent information that's then fed into the main program/function.

var threeDx = prompt("What is the starting value of X on the x-axis, in pixels?");
var threeDy = prompt("What is the starting value of Y on the y-axis, in pixels?");
var threeDz = prompt("What is the starting value of Z on the z-axis, in pixels?");
var i = prompt("How many iterations do you wish to create?");
var x_increment = prompt ("What is the incremental change in X that you wish to specify, in pixels?");
var counter = 0

$.writeln(threeDx);
$.writeln(threeDy);
$.writeln(threeDz);
$.writeln(i);
$.writeln(x_increment);


//function
//  I need to input the value of threeDx to make it work the first time through, and then increment threeDx for subsequent iterations.  Use "iterations" to name the file
// this first section sets the 3D camera stage, camera, etc.

var threeD_render = function(threeDx_i) {

var idsetthreeDCamera = stringIDToTypeID( "set3DCamera" );
    var desc49 = new ActionDescriptor();
    var idkeythreeDCurrentCameraPosition = stringIDToTypeID( "key3DCurrentCameraPosition" );
        var desc50 = new ActionDescriptor();
        var idkeythreeDXPos = stringIDToTypeID( "threeDx_i" );
        desc50.putDouble( idkeythreeDXPos, threeDx_i );
        var idkeythreeDYPos = stringIDToTypeID( "threeDy" );
        desc50.putDouble( idkeythreeDYPos, threeDy);
        var idkeythreeDZPos = stringIDToTypeID( "threeDz" );
        desc50.putDouble( idkeythreeDZPos, threeDz );
        var idkeythreeDXAngle = stringIDToTypeID( "key3DXAngle" );
        desc50.putDouble( idkeythreeDXAngle, -179.999954 );
        var idkeythreeDYAngle = stringIDToTypeID( "key3DYAngle" );
        desc50.putDouble( idkeythreeDYAngle, -0.000000 );
        var idkeythreeDZAngle = stringIDToTypeID( "key3DZAngle" );
        desc50.putDouble( idkeythreeDZAngle, -179.999756 );
    var idkeythreeDCurrentCameraPosition = stringIDToTypeID( "key3DCurrentCameraPosition" );
    desc49.putObject( idkeythreeDCurrentCameraPosition, idkeythreeDCurrentCameraPosition, desc50 );
    var idkeythreeDCurrentFStop = stringIDToTypeID( "key3DCurrentFStop" );
    desc49.putDouble( idkeythreeDCurrentFStop, 0.000000 );
    var idkeythreeDCurrentFDist = stringIDToTypeID( "key3DCurrentFDist" );
    desc49.putDouble( idkeythreeDCurrentFDist, 0.500000 );
    var idkeythreeDCurrentFocalPointX = stringIDToTypeID( "key3DCurrentFocalPointX" );
    desc49.putDouble( idkeythreeDCurrentFocalPointX, 0.500000 );
    var idkeythreeDCurrentFocalPointY = stringIDToTypeID( "key3DCurrentFocalPointY" );
    desc49.putDouble( idkeythreeDCurrentFocalPointY, 0.500000 );
    var idkeythreeDCurrentFOV = stringIDToTypeID( "key3DCurrentFOV" );
    desc49.putDouble( idkeythreeDCurrentFOV, 30.000000 );
    var idkeythreeDOrthographic = stringIDToTypeID( "key3DOrthographic" );
    desc49.putBoolean( idkeythreeDOrthographic, false );
    var idkeythreeDOrthographicScale = stringIDToTypeID( "key3DOrthographicScale" );
    desc49.putDouble( idkeythreeDOrthographicScale, 1896.008057 );
    var idkeythreeDRenderStereo = stringIDToTypeID( "key3DRenderStereo" );
    desc49.putBoolean( idkeythreeDRenderStereo, false );
    var idkeythreeDRenderStereoStyle = stringIDToTypeID( "key3DRenderStereoStyle" );
    desc49.putInteger( idkeythreeDRenderStereoStyle, 16384 );
    var idkeythreeDStereoOffset = stringIDToTypeID( "key3DStereoOffset" );
    desc49.putDouble( idkeythreeDStereoOffset, 5.000000 );
    var idkeythreeDStereoLenticularSpacing = stringIDToTypeID( "key3DStereoLenticularSpacing" );
    desc49.putDouble( idkeythreeDStereoLenticularSpacing, 40.000000 );
    var idkeythreeDStereoFocalPlane = stringIDToTypeID( "key3DStereoFocalPlane" );
    desc49.putDouble( idkeythreeDStereoFocalPlane, 0.000000 );
    var idkeythreeDStereoBarrier = stringIDToTypeID( "key3DStereoBarrier" );
    desc49.putDouble( idkeythreeDStereoBarrier, 0.000000 );
    var idkeythreeDStereoViewID = stringIDToTypeID( "key3DStereoViewID" );
    desc49.putInteger( idkeythreeDStereoViewID, 0 );
    var idkeythreeDStereoBackgroundDisparity = stringIDToTypeID( "key3DStereoBackgroundDisparity" );
    desc49.putDouble( idkeythreeDStereoBackgroundDisparity, 100.000000 );
    var idkeythreeDStereoBackgroundOffset = stringIDToTypeID( "key3DStereoBackgroundOffset" );
    desc49.putDouble( idkeythreeDStereoBackgroundOffset, 0.000000 );
    var idkeythreeDViewIndexString = stringIDToTypeID( "key3DViewIndexString" );
    desc49.putString( idkeythreeDViewIndexString, """""" );
executeAction( idsetthreeDCamera, desc49, DialogModes.NO );

// render the 3D image

var idrenderthreeDSelection = stringIDToTypeID( "render3DSelection" );
    var desc51 = new ActionDescriptor();
executeAction( idrenderthreeDSelection, desc51, DialogModes.NO );

//save the image as a .PSD File

var idsave = charIDToTypeID( "save" );
    var desc54 = new ActionDescriptor();
    var idAs = charIDToTypeID( "As  " );
        var desc55 = new ActionDescriptor();
        var idmaximizeCompatibility = stringIDToTypeID( "maximizeCompatibility" );
        desc55.putBoolean( idmaximizeCompatibility, true );
    var idPhtthree = charIDToTypeID( "Pht3" );
    desc54.putObject( idAs, idPhtthree, desc55 );
    var idIn = charIDToTypeID( "In  " );
    desc54.putPath( idIn, new File( "/Volumes/Mac SSD 750/Tim Mulholland's SSD/Photography/Reverspectives/Jan 2015 Experiments/Books/Sequence2/Books2-"+counter+".psd" ) );
    var idDocI = charIDToTypeID( "DocI" );
    desc54.putInteger( idDocI, 87 );
    var idLwCs = charIDToTypeID( "LwCs" );
    desc54.putBoolean( idLwCs, true );
    var idsaveStage = stringIDToTypeID( "saveStage" );
    var idsaveStageType = stringIDToTypeID( "saveStageType" );
    var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );
    desc54.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );
executeAction( idsave, desc54, DialogModes.NO );
};


//loop

for (var iterations = 0; iterations <= i; iterations++) {
    counter = counter+1
    var threeDx_i= threeDx-counter * x_increment
   threeD_render(threeDx_i);
   $.writeln (threeDx_i);
}
Illuminata Photo

Script stopped working - flummoxed

Post by Illuminata Photo »

I've still been working on this...

I just can't seem to get it to pass the X position variable into the function any longer...