Skip to main content
Known Participant
March 9, 2011
Answered

How to Get Internal Photoshop Values Given an ID

  • March 9, 2011
  • 1 reply
  • 2055 views

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:

<code>

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 =
      stringIDToTypeID("key3DCurrentCameraPosition");
    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);
    descCamera.putObject(idKey3DCurrentCameraPosition,
        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;
}

</code>

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:

<code>

    var ref = new ActionReference();
    ref.putIndex(idkeythreeDCurrentFStop, idkeythreeDCurrentFStop);
    var desc = executeActionGet(ref);
</code>

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.

This topic has been closed for replies.
Correct answer Michael_L_Hale

This will get you the 3DCurrentCameraPositon

var ref = new ActionReference();
ref.putEnumerated( zTID("Lyr "), zTID("Ordn"), zTID("Trgt") );
var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('layer3D')).getObjectValue(stringIDToTypeID('key3DState')).getObjectValue(stringIDToTypeID('key3DCurrentCameraPosition'));

That will return a descriptor with the following keys.

Key 0 = key3DXPos: DescValueType.DOUBLETYPE
Key 1 = key3DYPos: DescValueType.DOUBLETYPE
Key 2 = key3DZPos: DescValueType.DOUBLETYPE
Key 3 = key3DXAngle: DescValueType.DOUBLETYPE
Key 4 = key3DYAngle: DescValueType.DOUBLETYPE
Key 5 = key3DZAngle: DescValueType.DOUBLETYPE

At least with my sample 3D layer. I don't really do much with 3D so there may be other keys.

1 reply

Michael_L_HaleCorrect answer
Inspiring
March 9, 2011

This will get you the 3DCurrentCameraPositon

var ref = new ActionReference();
ref.putEnumerated( zTID("Lyr "), zTID("Ordn"), zTID("Trgt") );
var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('layer3D')).getObjectValue(stringIDToTypeID('key3DState')).getObjectValue(stringIDToTypeID('key3DCurrentCameraPosition'));

That will return a descriptor with the following keys.

Key 0 = key3DXPos: DescValueType.DOUBLETYPE
Key 1 = key3DYPos: DescValueType.DOUBLETYPE
Key 2 = key3DZPos: DescValueType.DOUBLETYPE
Key 3 = key3DXAngle: DescValueType.DOUBLETYPE
Key 4 = key3DYAngle: DescValueType.DOUBLETYPE
Key 5 = key3DZAngle: DescValueType.DOUBLETYPE

At least with my sample 3D layer. I don't really do much with 3D so there may be other keys.

Known Participant
March 10, 2011

Michael,

Wow.  Thanks for the information.  I didn't realize it worked that way.  I got what I needed and found all sorts of other useful stuff in there, "there" being the top-level ActionDescriptor from just executeActionGet(ref).

BTW how do you get code to appear in a window as in your reply?  I was trying to do that.

Thanks again.

Inspiring
March 11, 2011

Kenneth Evans wrote:

BTW how do you get code to appear in a window as in your reply?  I was trying to do that.

When you post a message there is a tool bar like area above where you type. One of the icons is >> if you click on that a popup menu appears. If you hover over Syntax Highlighting a dropdown appears. I choose Plain.