Photoshop CC Javascript to count number of frames in timeline

Explorer ,
Mar 20, 2021 Mar 20, 2021

Copy link to clipboard

Copied

I want to find a number of frames on the timeline and move the indicator to read the first frame and so on using javascript. I have tried with the below script which is not working on photoshop cc 2019. I can get only 0 as a number of frames.

 

var r = new ActionReference();

r.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('frameCount'));

r.putClass(stringIDToTypeID('timeline'));

var ret = executeActionGet(r);

alert( ret.getInteger(stringIDToTypeID('frameCount')) );

 

I am attaching the timeline and screenshot and PSD for reference.

 

Karthikeyan98A2_0-1616292293305.png

 

Thanks

TOPICS
Actions and scripting, How to

Views

122

Likes

translate

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 2 Correct Answers

Adobe Community Professional , Mar 20, 2021 Mar 20, 2021

Likes

translate

Translate

Translate
Adobe Community Professional , Mar 20, 2021 Mar 20, 2021
As r-bin gave you the code to get the number of frames, here is that plus how to go to a particular frame:     var r = new ActionReference(); r.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('frameCount')); r.putClass(stringIDToTypeID('animationClass')); var ret = executeActionGet(r); goToFrame(1)//enter frame you want to goto here. now it shows the first frame; function goToFrame(frameNum){ var idslct = charIDToTypeID( "slct" ); var desc2 = new ActionDescriptor(); va...

Likes

translate

Translate

Translate
Adobe Community Professional ,
Mar 20, 2021 Mar 20, 2021

Copy link to clipboard

Copied

Likes

translate

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
Explorer ,
Mar 20, 2021 Mar 20, 2021

Copy link to clipboard

Copied

Thanks r-bin. It works great. I also need to move the indicator to read the first frame and so on using javascript. Can you please help me with that?

Likes

translate

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
Adobe Community Professional ,
Mar 20, 2021 Mar 20, 2021

Copy link to clipboard

Copied

As r-bin gave you the code to get the number of frames, here is that plus how to go to a particular frame:

 

 

var r = new ActionReference();
r.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('frameCount'));
r.putClass(stringIDToTypeID('animationClass'));
var ret = executeActionGet(r);

goToFrame(1)//enter frame you want to goto here. now it shows the first frame;

function goToFrame(frameNum){
    var idslct = charIDToTypeID( "slct" );
        var desc2 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref1 = new ActionReference();
            var idanimationFrameClass = stringIDToTypeID( "animationFrameClass" );
            ref1.putIndex( idanimationFrameClass, frameNum );
        desc2.putReference( idnull, ref1 );
    executeAction( idslct, desc2, DialogModes.NO );
    }

 

Likes

translate

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
Explorer ,
Mar 20, 2021 Mar 20, 2021

Copy link to clipboard

Copied

Thank you very much for helping me with this Chuck Uebele. It's working as expected.

Likes

translate

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