• 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.0K

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

Valorous Hero , 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
Valorous Hero ,
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')) );

//

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

Copy link to clipboard

Copied

And again. Thanks alot r-bin.

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
Valorous Hero ,
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

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
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.

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
Valorous Hero ,
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.

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
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 );

    }

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
Valorous Hero ,
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

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

Copy link to clipboard

Copied

WOW.

Thanks a lot, r-bin. Really appreciate.

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
Valorous Hero ,
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.

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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
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.

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

Copy link to clipboard

Copied

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

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 ,
Jan 13, 2022 Jan 13, 2022

Copy link to clipboard

Copied

is this get_props the same as the function we see here
below is that function, i dont see a zip or something called get_props

function get_adjustment_rawdata(id)
    {
    return get_prop_value("layer", id, "adjustment", 0, "legacyContentData");
    }



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
LEGEND ,
Jan 13, 2022 Jan 13, 2022

Copy link to clipboard

Copied

Hopefully r-bin can edit his link to reupload original .zip, so we can know how it is 😉

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 ,
Jan 13, 2022 Jan 13, 2022

Copy link to clipboard

Copied

This info was the gold for me, with this info i was able to make my global timeline scrubber work 🙂
Its works a bit like that one of After Effects, So in combination with the zoomed in time we get from Photoshop, this global one acts on the zoomed out version. Works on both Windows and OSX, is part of AnimDessin2 toolbar im doing updates for.

Its the timeline below those icons, i can make it show frames or timecode. When clicking it will set the timeindicator to the correct layer aka time in timeline. Sadly i dont know how i twould be able to get the correct layer below it. There is no code for. I tought perhaps use layer count. But we sometimes uses frames which are longer, so that would mess it up.

 

Its perhaps a bit hard to tell whats going on. But when you make an animation with a longer timeline and you are zoomed in on the timeline (lower panel), then scrolling left and right is a bit tedious. Therefor the global timeline is usefull. It will always show the full with of the timeline below those icons. So when you click, you see the bottom timeline jump to the correct part. The user only needs to select the frame below the indicator. 
Its the time line below those icons at the topIts the time line below those icons at the top

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
LEGEND ,
Jan 13, 2022 Jan 13, 2022

Copy link to clipboard

Copied

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 ,
Jan 13, 2022 Jan 13, 2022

Copy link to clipboard

Copied

LATEST

Note that this is still in development stage, most function works properly now. I need to push my latest work now i got the last parts of this new document dialog working. I also need to figure out the parts like zxp and perhaps got to UXP, which i really dont like. 

 

PS in this post on the original repo, you can see the progress i made and work ive done on this panel. Its quite a lot, for me it was nice learning a bit more about panels. I wanted to expand the panel with more functionality. Added lots feats like multiple actions under 1 button, actions can be applied to multiple layers now. The timeline scrubber, an info panel and a video info panel. I added localization, still wip as my new document panels was still not finished. This is quite a monter to localize, need to figure out how can do this one.

https://github.com/sbaril/Photoshop-Animation/issues/8

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