Skip to main content
salithan73779666
Participating Frequently
November 1, 2017
Answered

Is there any way to get frame count of timeline animation using JSX script?

  • November 1, 2017
  • 1 reply
  • 8328 views

I want to extract frame count using JSX script?
I have used following code. But it seems not sharp as expected (In case of decimal point of seconds it seems not good)

function getTimelineLength() {

    var ref = new ActionReference();

    ref.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('duration'));

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

    var desc = new ActionDescriptor();

    desc.putReference(charIDToTypeID('null'), ref);

    var TC = executeAction(charIDToTypeID('getd'), desc, DialogModes.NO);

    TC = TC.getObjectValue(stringIDToTypeID('duration'));

    var M = 0;

    try { M = TC.getInteger(stringIDToTypeID('minutes')); } catch (e) { }

    var S = 0;

    try { S = TC.getInteger(stringIDToTypeID('seconds')); } catch (e) { }

    var F = TC.getInteger(stringIDToTypeID('frame'));

    var FR = TC.getInteger(stringIDToTypeID('frameRate'));

    var A = new Array();

    A.push([[M], [S], [F], [FR]]);

    return A;

}

//option 1

var frameCount = timeLineInfo[0][2]  ( But this returns "0" value with newly opened document)

//option 2

var timeLineInfo =  getTimelineLength()

var frameCount = timeLineInfo[0][1] * timeLineInfo[0][3]  ( This is not returns correct value with decimal value of seconds )

Anyone have a better solution?

This topic has been closed for replies.
Correct answer r-bin

var r = new ActionReference();

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

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

var ret = executeActionGet(r);

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

//

1 reply

r-binCorrect answer
Legend
November 1, 2017

var r = new ActionReference();

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

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

var ret = executeActionGet(r);

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

//

salithan73779666
Participating Frequently
November 1, 2017

And again. Thanks alot r-bin.

Legend
November 1, 2017

Thanks, r-bin. Very helpful.


Is there any documentation regarding these details?

I have tried using ScriptListener, but I could found a way to access and identify property details using output scripts.


This is my personal hacking experience. )
You can download
Adobe Photoshop SDK and find in the file "PITerminology.h" the names of all the strings and chars for stringIDToTypeID or charIDToTypeID functions. Then you can write a script that checks the availability of the desired property for the object or class scrolling through all the strings. If successful, you can get the type of property and its data.

Sorry for the bad english.