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

Is there anyway to identify keyframe of timeline animation using JSX script?

Community Beginner ,
Oct 31, 2017 Oct 31, 2017

I need to retrieve animation data of keyframes( Only keyframes ) of video animation
I am using following code to iterate timeline. But still, I couldn't identify keyframes

Is there any way to identify keyframes?

function gotoFrame(Seconds, Frame, frameRate) {

    var desc69 = new ActionDescriptor();

    var ref33 = new ActionReference();

    ref33.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('time'));

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

    desc69.putReference(charIDToTypeID('null'), ref33);

    var desc70 = new ActionDescriptor();

    desc70.putInteger(stringIDToTypeID('seconds'), Seconds);

    desc70.putInteger(stringIDToTypeID('frame'), Frame);

    desc70.putDouble(stringIDToTypeID('frameRate'), frameRate);

    desc69.putObject(charIDToTypeID('T   '), stringIDToTypeID('timecode'), desc70);

    executeAction(charIDToTypeID('setd'), desc69, DialogModes.NO);

};

unction getCurrentFrame() {

    try {

        var ref = new ActionReference();

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

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

        var desc = new ActionDescriptor();

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

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

        return TC.getInteger(stringIDToTypeID('currentFrame'));

    } catch (e) { return null; }

};

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([, , , [FR]]);

    return A;

}

var timeLineLenth = getTimelineLength();

var doc = activeDocument;

for (var i = 0; i <= timeLineLenth[0][1]; i++) {

    for (var j = 0; j < timeLineLenth[0][3]; j++) {

        gotoFrame(i, j, 30);

        var a = getCurrentFrame();

    }

}

TOPICS
Actions and scripting
2.0K
Translate
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 , Oct 31, 2017 Oct 31, 2017

I do not use animation at all, but maybe the following functions will be useful, i hope

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

    }

functio

...
Translate
Adobe
People's Champ ,
Oct 31, 2017 Oct 31, 2017

I do not use animation at all, but maybe the following functions will be useful, i hope

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

    }

function prev_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( "previousKeyframe" ), d1, DialogModes.NO );

    }

Translate
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 ,
Oct 31, 2017 Oct 31, 2017

Thanks a lot r-bin

Translate
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
Enthusiast ,
Nov 15, 2017 Nov 15, 2017

I tried to brute force on Action Manager code above with 5000+ stringIDs properties and this is only I can get.

documentTimelineSettings{ 

   "_obj":"object",

   "duration":{ 

      "_obj":"timecode",

      "frame":0.0,

      "frameRate":30.0,

      "seconds":5.0

   },

   "frameRate":30.0

}

duration{ 

   "_obj":"object",

   "duration":{ 

      "_obj":"timecode",

      "frame":0.0,

      "frameRate":30.0,

      "seconds":5.0

   }

}

enabled{ 

   "_obj":"object",

   "enabled":true

}

frameRate{ 

   "_obj":"object",

   "frameRate":30.0

}

time{ 

   "_obj":"object",

   "time":{ 

      "_obj":"timecode",

      "frame":2.0,

      "frameRate":30.0,

      "seconds":1.0

   }

}

workInTime{ 

   "_obj":"object",

   "workInTime":{ 

      "_obj":"timecode",

      "frame":0.0,

      "frameRate":30.0,

      "seconds":0.0

   }

}

workOutTime{ 

   "_obj":"object",

   "workOutTime":{ 

      "_obj":"timecode",

      "frame":0.0,

      "frameRate":30.0,

      "seconds":5.0

   }

Translate
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
People's Champ ,
Nov 15, 2017 Nov 15, 2017
LATEST

And I found that

class "timeline" has properties:

time [ActionDescriptor]

currentFrame  INTEGERTYPE

documentTimelineSettings [ActionDescriptor] 

duration [ActionDescriptor]

enabled  BOOLEANTYPE

frameCount  INTEGERTYPE

frameRate  DOUBLETYPE

hasMotion  BOOLEANTYPE

workInTime [ActionDescriptor]

workOutTime [ActionDescriptor]

class "animationFrameClass" has properties:

animationFrameDelay  DOUBLETYPE

animationFrameReplace  ENUMERATEDTYPE animationFrameReplaceType.animationFrameReplaceAutoDispose

class "animationClass" has properties:

animationLoopCount INTEGERTYPE

currentFrame  INTEGERTYPE

enabled  BOOLEANTYPE

frameCount  INTEGERTYPE

)

Translate
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