10 Replies Latest reply on Sep 18, 2011 10:50 PM by billablubb2

    How to Get Internal Photoshop Values Given an ID

    Kenneth Evans

      I am having trouble getting values for internal settings.  It is less hard to set them, as you can use the Script Listener to get the code to use.  Presumably you use executeActionGet() with an ActionReference.  The problem is knowing how to construct the ActionReference.  There does not seem to be much documentation on this.


      My immediate problem is how to get the 3D Camera settings. I realize this requires Photoshop Extended, but the principle should be the same.  This code sucessfully sets these settings:



      function setPhotoshopCamera(angleX, angleY, angleZ, posX, posY, posZ) {
          // Camera
          var idGet3DCamera = stringIDToTypeID( "get3DCamera" );
          var idSet3DCamera = stringIDToTypeID( "set3DCamera" );
          var descCamera = new ActionDescriptor();
          // Camera position
          var idKey3DCurrentCameraPosition =
          var descCameraPosition = new ActionDescriptor();
          var idkeythreeDXPos = stringIDToTypeID("key3DXPos");
          descCameraPosition.putDouble(idkeythreeDXPos, posX);
          var idkeythreeDYPos = stringIDToTypeID("key3DYPos");
          descCameraPosition.putDouble(idkeythreeDYPos, posY);
          var idkeythreeDZPos = stringIDToTypeID("key3DZPos");
          descCameraPosition.putDouble(idkeythreeDZPos, posZ);
          var idkeythreeDXAngle = stringIDToTypeID("key3DXAngle");
          descCameraPosition.putDouble(idkeythreeDXAngle, angleX);
          var idkeythreeDYAngle = stringIDToTypeID("key3DYAngle");
          descCameraPosition.putDouble(idkeythreeDYAngle, angleY);
          var idkeythreeDZAngle = stringIDToTypeID("key3DZAngle");
          descCameraPosition.putDouble(idkeythreeDZAngle, angleZ);
              idKey3DCurrentCameraPosition, descCameraPosition);
          // These need to be defined in the ActionDescriptor for it to work,

          //   but we don't have them
          var idkeythreeDCurrentFStop = stringIDToTypeID( "key3DCurrentFStop" );
          descCamera.putDouble( idkeythreeDCurrentFStop, 0.000000 );
          var idkeythreeDCurrentFDist = stringIDToTypeID( "key3DCurrentFDist" );
          descCamera.putDouble( idkeythreeDCurrentFDist, 0.500000 );
          var idkeythreeDCurrentFocalPointX = stringIDToTypeID( "key3DCurrentFocalPointX" );
          descCamera.putDouble( idkeythreeDCurrentFocalPointX, 0.500000 );
          var idkeythreeDCurrentFocalPointY = stringIDToTypeID( "key3DCurrentFocalPointY" );
          descCamera.putDouble( idkeythreeDCurrentFocalPointY, 0.500000 );
          var idkeythreeDCurrentFOV = stringIDToTypeID( "key3DCurrentFOV" );
          descCamera.putDouble( idkeythreeDCurrentFOV, 30.000000 );
          var idkeythreeDOrthographic = stringIDToTypeID( "key3DOrthographic" );
          descCamera.putBoolean( idkeythreeDOrthographic, false );
          var idkeythreeDOrthographicScale = stringIDToTypeID( "key3DOrthographicScale" );
          descCamera.putDouble( idkeythreeDOrthographicScale, 6.928203 );
          var idkeythreeDViewIndexString = stringIDToTypeID( "key3DViewIndexString" );
          descCamera.putString( idkeythreeDViewIndexString, "" );

          var desc = executeAction(idSet3DCamera, descCamera, DialogModes.ALL);
          return desc;



      The problem is that it does not work unless you also set the lower items.  I want to leave these as they are currently set, but I don't know how to get those values.  Independently of this, I would also like to get the camera position values beforehand.  The 9 IDs, string or otherwise, that should be necessary are known from above.


      I presume you would use something like:



          var ref = new ActionReference();
          ref.putIndex(idkeythreeDCurrentFStop, idkeythreeDCurrentFStop);
          var desc = executeActionGet(ref);


      However, I have been unable to get anything to work.  I am not certain

      1. Which of the putXXX method to use.
      2. What to use for the desiredClass, which is the first argument.


      Any help would be appreciated.