I’m working on a thingy that involves the Photoshop video timeline and I would like to programmatically query the current frame that the document is on. It’s proving more difficult than expected. If someone here is an expert at interpreting action references and descriptors, I’d appreciate tips.
My current approach is the following: I used the ScriptingListener to find out the command used to set the current frame. Then I try to guess how to construct the corresponding get action (with help of the following documents from the Photoshop SDK: /pluginsdk/documentation/html/_p_i_string_terminology_8h.html, /pluginsdk/documentation/html/_p_i_terminology_8h.html, SDK download available here https://www.adobe.com/devnet/photoshop/sdk.html).
Not much success yet. Not surprising as I’m pretty much shooting in the dark here. Figuring out how to set values is easy (do something in UI and record the API call) but I’m not aware of any easy method for deriving the getters. There’s no “get current frame number” button anywhere :laugh:
ScriptingListener + removing a couple of extra lines yielded the following working code (the recorded action sets frame rate and used seconds+frames as the unit, I do not need to set frame rate and use frame index as unit so I removed those lines and tested that the code still worked):
var desc1 = new ActionDescriptor(); var ref1 = new ActionReference(); ref1.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID( "time" ) ); ref1.putClass( stringIDToTypeID( "timeline" ) ); desc1.putReference( charIDToTypeID( "null" ), ref1 ); var desc2 = new ActionDescriptor(); desc2.putInteger( stringIDToTypeID( "frame" ), frameNumber ); desc1.putObject( charIDToTypeID( "T " ), stringIDToTypeID( "timecode" ), desc2 ); executeAction( charIDToTypeID( "setd" ), desc1, DialogModes.NO );
This is how I’m trying to get the current frame from Photoshop at the moment:
var frameNumber; var desc1 = new ActionDescriptor(); var ref1 = new ActionReference(); ref1.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID( "time" ) ); ref1.putClass( stringIDToTypeID( "timeline" ) ); desc1.putReference( charIDToTypeID( "null" ), ref1 ); frameNumber = executeAction( charIDToTypeID( "getd" ), desc1, DialogModes.NO ); return frameNumber;
As you can tell, I’m confused. Ideally Adobe would have made things like this easily queryable from the document object tree, but AFAIK the timeline stuff needs to be accessed with the less-approachable executeAction calls. How to derive which properties and classes of which type I need to traverse to get to the info I’m after?