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

Photoshop CC Javascript to count number of frames in timeline

Explorer ,
Mar 20, 2021 Mar 20, 2021

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
926
Translate
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

People's Champ , Mar 20, 2021 Mar 20, 2021
Translate
Community Expert , 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
...
Translate
Adobe
People's Champ ,
Mar 20, 2021 Mar 20, 2021
Translate
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

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?

Translate
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 Expert ,
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();
        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 );
    }

 

Translate
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
LATEST

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

Translate
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