Skip to main content
Inspiring
January 31, 2017
Question

How to get animation frame ID?

  • January 31, 2017
  • 2 replies
  • 967 views

Hello!

I'm trying to get identifiers of frames on the timeline panel (Frame animation mode).

I see, that they are stored inside Image Resource Section of PSD file.

Resource ID is 4000 (0x0fa0) which is supposed to be used by plug-ins.

But I can't figure out how to get them using javascript or OLE-automation. Is it possible?

And if not, is it possible to read them from C/C++ plug-in and send to javascript?

This topic has been closed for replies.

2 replies

oliverIntergrafika
Inspiring
February 1, 2017

Is there a way to get the current timeline frame number in Frame Animation mode?
.

I had this same question a while ago. But no real solution exists as I know.

If You are in an extension panel, You can listen to JSONEvents from PS. One of these events is SELECT which is mirroring Timeline frame changes:


{"_obj":"select","null":{"_index":1,"_ref":"animationFrameClass"}}

But You still don't know which is the actual frame when You open or switch to a fresh .psd.

SuperMerlin
Inspiring
January 31, 2017
Inspiring
February 1, 2017

That works with video timeline only. For frame animation there is "animationClass" and "animationFrameClass" and I know how to select frames and get/set delays, but not the ID.

SuperMerlin
Inspiring
February 1, 2017

Would this work to get the current frame selected?

function currentFrameNumber(){

   var ref = new ActionReference();

   ref.putProperty( charIDToTypeID('Prpr') , charIDToTypeID('NmbL'))

   ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

   var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;

backGround = activeDocument.artLayers[activeDocument.artLayers.length - 1].isBackgroundLayer ? 0 : 1;

   for(i=backGround; i<count; i++){

        ref = new ActionReference();

        ref.putIndex( charIDToTypeID( 'Lyr ' ), i );

        var desc = executeActionGet(ref);

        var adjustment = false;

        if(desc.getBoolean(stringIDToTypeID('visible'))) return i;

   }

};

alert(currentFrameNumber());