Copy link to clipboard
Copied
Is there an API for manipulating the timeline? I didn't see anything about it in the JS API pdf, and after briefly scanning the object hierarchy in the toolkit, I didn't see it. I'd like to be able to create new frames, jump to specific frames, remove frames, etc.
I think – only with script listener code.
For example you can do this:
...// go to frame number 2
var jumpToFrameNumber = 2; // counts from 1
var desc = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putIndex( stringIDToTypeID( "animationFrameClass" ), jumpToFrameNumber );
desc.putReference( charIDToTypeID( "null" ), ref1 );
executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
// delete active frame
var desc1 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putEnume
Copy link to clipboard
Copied
I think – only with script listener code.
For example you can do this:
// go to frame number 2
var jumpToFrameNumber = 2; // counts from 1
var desc = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putIndex( stringIDToTypeID( "animationFrameClass" ), jumpToFrameNumber );
desc.putReference( charIDToTypeID( "null" ), ref1 );
executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
// delete active frame
var desc1 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putEnumerated( stringIDToTypeID( "animationFrameClass" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc1.putReference( charIDToTypeID( "null" ), ref2 );
executeAction( charIDToTypeID( "Dlt " ), desc1, DialogModes.NO );
Also you can do something like this:
executeAction( stringIDToTypeID( "convertTimeline" ), new ActionDescriptor(), DialogModes.NO );
// or
//executeAction( stringIDToTypeID( "convertAnimation" ), new ActionDescriptor(), DialogModes.NO );
// and this
// the name say all
executeAction( stringIDToTypeID( "animationFramesFromLayers" ), new ActionDescriptor(), DialogModes.NO );
Have fun
Copy link to clipboard
Copied
I've installed the script listener plugin and that seems to work great. Thank you. One question though. How do I figure out commands the script listener won't normally listen for? For example, I can add frames and select frames and see that in the log, but how can I figure out how many frames are already there?
Copy link to clipboard
Copied
I don't think there is a short easy way to explain how to work with Action Manager( other than mining the scriptlistener log ). And there isn't much offical documentaion on using Action Manager.
Here is how to get the number of frames and the framerate.
function GetFrameCount(){
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( 'Prpr' ), stringIDToTypeID( "frameCount" ) );
ref.putClass( stringIDToTypeID( "timeline" ) );
var desc = new ActionDescriptor();
desc.putReference( charIDToTypeID( 'null' ), ref );
var resultDesc = executeAction( charIDToTypeID( 'getd' ), desc, DialogModes.NO );
return resultDesc.getInteger( stringIDToTypeID( "frameCount" ) );
};
function GetFrameRate(){
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( 'Prpr' ), stringIDToTypeID("documentTimelineSettings") );
ref.putClass( stringIDToTypeID( "timeline" ) );
var desc = new ActionDescriptor();
desc.putReference( charIDToTypeID( 'null' ), ref );
var resultDesc = executeAction( charIDToTypeID( 'getd' ), desc, DialogModes.NO );
return resultDesc.getDouble( stringIDToTypeID('frameRate') );
};
Copy link to clipboard
Copied
Hi Michael,
These functions (GetFrameCount(), GetFrameRate()) are working on Video Timeline only. Is there a similar solution for Frame Animation?
Thanks a lot!