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

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

Community Beginner ,
Nov 01, 2017 Nov 01, 2017

Copy link to clipboard

Copied

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?

TOPICS
Actions and scripting

Views

5.8K

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

People's Champ , Nov 01, 2017 Nov 01, 2017

var r = new ActionReference();

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

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

var ret = executeActionGet(r);

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

//

Votes

Translate

Translate
Adobe
Community Expert ,
Oct 07, 2024 Oct 07, 2024

Copy link to clipboard

Copied

LATEST

Screenshot 2024-10-07 at 11.22.19.png

// determine durations in a frame animation;
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theNumbers = new Array;
var theCounter = 1;
var theCheck = selectFrame (theCounter);
//var theFrameCount = GetFrameCount();
while (theCheck != false) {
var theDur = getFrameDelay(theCounter);
theCounter++;
theNumbers.push(theDur);
var theCheck = selectFrame (theCounter);
};
alert ("durations\n"+theNumbers.join("\n"))
};
////////////////////////////////////
////// get frame delay //////
function getFrameDelay (theIndex) {
try {
var ref = new ActionReference();  
ref.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('animationFrameDelay'));  
ref.putIndex(stringIDToTypeID('animationFrameClass'), theIndex);
var desc = new ActionDescriptor();  
desc.putReference(charIDToTypeID('null'), ref);           
var aaa = executeAction(charIDToTypeID('getd'), desc, DialogModes.NO);
return aaa.getDouble(stringIDToTypeID('animationFrameDelay'))
} catch (e) {return false}
};
////// select frame //////
function selectFrame (theIndex) {
try {
var desc18 = new ActionDescriptor();
var ref10 = new ActionReference();
ref10.putIndex( stringIDToTypeID( "animationFrameClass" ), theIndex );
desc18.putReference( charIDToTypeID( "null" ), ref10 );
executeAction( charIDToTypeID( "slct" ), desc18, DialogModes.NO );
return true
} catch (e) {return false}
};

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
Advocate ,
Sep 21, 2024 Sep 21, 2024

Copy link to clipboard

Copied

This panel works for frame animation, not the video style method. As @c.pfaffenbichler states, an simple example file would help pinpoint possible issue

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