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

3.1K

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 1 Correct Answer

Adobe Community Professional , 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')) );//

Likes

translate

Translate

Translate
Adobe Community Professional ,
Nov 01, 2017 Nov 01, 2017

Copy link to clipboard

Copied

var r = new ActionReference();

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

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

var ret = executeActionGet(r);

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

//

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
Community Beginner ,
Nov 01, 2017 Nov 01, 2017

Copy link to clipboard

Copied

And again. Thanks alot r-bin.

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 ,
Nov 01, 2017 Nov 01, 2017

Copy link to clipboard

Copied

You also can get next properties of tilmeline

time

currentFrame

documentTimelineSettings

duration

enabled

frameCount

frameRate

hasMotion

workInTime

workOutTime

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
Community Beginner ,
Nov 01, 2017 Nov 01, 2017

Copy link to clipboard

Copied

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.

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 ,
Nov 01, 2017 Nov 01, 2017

Copy link to clipboard

Copied

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.

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
Community Beginner ,
Nov 01, 2017 Nov 01, 2017

Copy link to clipboard

Copied

Understood very well.

I observed several scripts, But still couldn't understand the pattern of coding.

If you have time, Could you please explain how did you construct below two sample scripts.

var r = new ActionReference();

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

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

var ret = executeActionGet(r);

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

-------------------------------------------------------------------------

function next_key_frame()

    {

    var d1 = new ActionDescriptor();

    var d2 = new ActionDescriptor();

    d2.putEnumerated( stringIDToTypeID( "trackID" ), stringIDToTypeID( "stdTrackID" ), stringIDToTypeID( "sheetPositionTrack" ) );

    d1.putObject( stringIDToTypeID( "trackID" ), stringIDToTypeID( "animationTrack" ), d2 );

    executeAction( stringIDToTypeID( "nextKeyframe" ), d1, 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
Adobe Community Professional ,
Nov 01, 2017 Nov 01, 2017

Copy link to clipboard

Copied

ok.

The second script I got using ScriptListener.
And the first one I got using this script to get a list of available properties.

a.jsx.zip - Google Drive

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
Community Beginner ,
Nov 01, 2017 Nov 01, 2017

Copy link to clipboard

Copied

WOW.

Thanks a lot, r-bin. Really appreciate.

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 ,
Nov 02, 2017 Nov 02, 2017

Copy link to clipboard

Copied

))

There is an extended version of the script where you can see the values of simple property types or browse the properties of complex objects like OBJECT, LIST, REFERENCE, RAWTYPE, etc.  to any depth.

But it only works on CS6 since on CC broke multi-column listboxies.

I can post link later if necessary.

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
Community Beginner ,
Nov 02, 2017 Nov 02, 2017

Copy link to clipboard

Copied

Yes, Please post it r-bin. I will be very useful.

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 ,
Nov 02, 2017 Nov 02, 2017

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 ,
Jun 23, 2020 Jun 23, 2020

Copy link to clipboard

Copied

Hello r-bin, 

Unfortunately, the link doesn't work now. Could you please update it. I am really eager to know how did you get those properties of the timeline, what was the process. Thank you.

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 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

Probably that's the same that was in zip file: get_props

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