• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Are there Javascript hooks to manipulate the timeline?

Community Beginner ,
Oct 23, 2013 Oct 23, 2013

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. 

TOPICS
Actions and scripting

Views

2.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 23, 2013 Oct 23, 2013

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

...

Votes

Translate

Translate
Adobe
Community Expert ,
Oct 23, 2013 Oct 23, 2013

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 24, 2013 Oct 24, 2013

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? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 24, 2013 Oct 24, 2013

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') );

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 12, 2015 Dec 12, 2015

Copy link to clipboard

Copied

LATEST

Hi Michael,

These functions (GetFrameCount(), GetFrameRate()) are working on Video Timeline only. Is there a similar solution for Frame Animation?

Thanks a lot!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines