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

How to get the seconds on a frame from the timeline

Community Beginner ,
Mar 14, 2023 Mar 14, 2023

Copy link to clipboard

Copied

We use the Frame Animation Timline to animate some things for our project, and we want to write a JavaScript tool to export the frame timings to a format that can be read by the rest of our content pipeline. 

 

With the script logging plugin, I've managed to capture how the data is set. But admittedly don't know how to go about pulling the data out of the currently selected frame. 

var idsetd = charIDToTypeID( "setd" );
    var desc230 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idanimationFrameClass = stringIDToTypeID( "animationFrameClass" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref1.putEnumerated( idanimationFrameClass, idOrdn, idTrgt );
    desc230.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var desc231 = new ActionDescriptor();
        var idanimationFrameDelay = stringIDToTypeID( "animationFrameDelay" );
        desc231.putDouble( idanimationFrameDelay, 1.000000 );
    var idanimationFrameClass = stringIDToTypeID( "animationFrameClass" );
    desc230.putObject( idT, idanimationFrameClass, desc231 );
executeAction( idsetd, desc230, DialogModes.NO );

 

TOPICS
Actions and scripting , Windows

Views

632

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

Community Beginner , Mar 15, 2023 Mar 15, 2023

With the help of c.pfaffenbickler, was able to get something put together. Here was my final result to get the frame time of the currently select frame. 

function GetFrameTime()
{
    var r = new ActionReference();
    r.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('animationFrameDelay'));
    r.putClass(stringIDToTypeID('animationFrameClass'));
    var ret = executeActionGet(r);
    return ret.getDouble(stringIDToTypeID('animationFrameDelay'));
}

 

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

I don’t know who originally presented this code, I cannot locate the thread over on ps-scripts.com anymore. 

function getFrameRate() {
   
   var actionRef = new ActionReference();
   actionRef.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID("frameRate"));
   actionRef.putClass(stringIDToTypeID("timeline"));

   var desc=new ActionDescriptor();
   desc.putReference(charIDToTypeID('null'), actionRef);
         
   var TC=executeAction(charIDToTypeID('getd'), desc, DialogModes.NO);
   var frameRate=TC.getDouble(stringIDToTypeID("frameRate"));

   return frameRate;
}

function getFrame(IO) {

   if (IO == "in") var tIO = stringIDToTypeID("workInTime");
   if (IO == "out") var tIO = stringIDToTypeID("workOutTime");
   if (IO == "playHead") var tIO = stringIDToTypeID("time");

   var fr = 0;
   var secs = 0;
   var mins = 0;
   var hrs = 0;
   var frRate = 30.0;
   
   var rate = stringIDToTypeID("frameRate");
   var frame = stringIDToTypeID("frame");
   var seconds = stringIDToTypeID("seconds");
   var minutes = stringIDToTypeID("minutes");
   var hours = stringIDToTypeID("hours");

   var tLine=stringIDToTypeID("timeline");
   var get=charIDToTypeID('getd');
   var nul=charIDToTypeID('null');
   var prop=charIDToTypeID('Prpr');
   
   var actionRef = new ActionReference();
   actionRef.putProperty(prop,tIO);
   actionRef.putClass(tLine);

   var desc=new ActionDescriptor();
   desc.putReference(nul, actionRef);
         
   var TC=executeAction(get,desc,DialogModes.NO);
   var TL=TC.getObjectValue(tIO);
   
   try {fr=TL.getInteger(frame);} catch(e){}
   try {secs=TL.getInteger(seconds);} catch(e){}
   try {mins=TL.getInteger(minutes);} catch(e){}
   try {hrs=TL.getInteger(hours);} catch(e){}
   frRate = TL.getDouble(rate);

   return hrs * 3600 * frRate + mins * 60 * frRate + secs * frRate + fr;

}
alert(getFrame("in"));
alert(getFrame("out"));
alert(getFrame("playHead"));

alert(getFrameRate());

 

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 ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

I don't think that's it. That looks like that's for the Video Timeline, since it has lead in/out times and everything. I'm trying to get the frame time from the Frame Animation timeline, the "animationFrameClass." At least when it came to some GoToFrame() stuff I saw in another thread, though they occupy the same space they are two rather seperate systems under the hood. 

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 ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

But I will say, the fact I can see how to use"getd" in there as a means of accessing data may mean I can find a path forward, so 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
Community Beginner ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

LATEST

With the help of c.pfaffenbickler, was able to get something put together. Here was my final result to get the frame time of the currently select frame. 

function GetFrameTime()
{
    var r = new ActionReference();
    r.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('animationFrameDelay'));
    r.putClass(stringIDToTypeID('animationFrameClass'));
    var ret = executeActionGet(r);
    return ret.getDouble(stringIDToTypeID('animationFrameDelay'));
}

 

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