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

Photoshop: Ability to access "animationFrameDelay" and "animationLoopCount" via scripting

Explorer ,
Nov 17, 2014 Nov 17, 2014

Copy link to clipboard

Copied

At our company, we are using Photoshop to animate 2D sprites for video games. To export the files from Photoshop, we are using custom scripts. However, our programmers encounterted a couple of problems with some of the functionality here.

First of all, there does not seem to be a documented API for large portions of the animation segment of Photoshop. However, this is one of the most important parts for automation, since it is very time consuming to manipulate each frame manually.

We've encountered two similar problems here:

var id45 = charIDToTypeID( "setd" );
var desc21 = new ActionDescriptor();
var id46 = charIDToTypeID( "null" );
var ref42 = new ActionReference();
var id47 = stringIDToTypeID( "animationFrameClass" );
var id48 = charIDToTypeID( "Ordn" );
var id49 = charIDToTypeID( "Trgt" );
ref42.putEnumerated( id47, id48, id49 );
desc21.putReference( id46, ref42 );
var id50 = charIDToTypeID( "T " );
var desc22 = new ActionDescriptor();
var id51 = stringIDToTypeID( "animationFrameDelay" );
desc22.putDouble( id51, 10.000000 );
var id52 = stringIDToTypeID( "animationFrameClass" );
desc21.putObject( id50, id52, desc22 );
executeAction( id45, desc21, DialogModes.NO );

In this example, the frame exposure is set to 10.0. However, the reference of "animationFrameClass" is zero, which means this value can only be read but not written.

The second example is this:

var idsetd = charIDToTypeID( "setd" );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idanimationClass = stringIDToTypeID( "animationClass" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref1.putEnumerated( idanimationClass, idOrdn, idTrgt );
desc2.putReference( idnull, ref1 );
var idT = charIDToTypeID( "T " );
var desc3 = new ActionDescriptor();
var idanimationLoopCount = stringIDToTypeID( "animationLoopCount" );
desc3.putInteger( idanimationLoopCount, 6 );
var idanimationClass = stringIDToTypeID( "animationClass" );
desc2.putObject( idT, idanimationClass, desc3 );
executeAction( idsetd, desc2, DialogModes.NO );

Here we are trying to set the loop count to 6 and we encounter a similar problem as described above.

Thank you!
Idea No status

Views

117

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
6 Comments
Adobe Employee ,
Nov 17, 2014 Nov 17, 2014

Copy link to clipboard

Copied

What version of Photoshop are you running? What OS/version are you on?

Votes

Translate

Translate

Report

Report
Adobe Employee ,
Nov 17, 2014 Nov 17, 2014

Copy link to clipboard

Copied

Hi Hannes,

I ran the code snippets you provided and they worked. I did have to change the charIDToTypeID( "T " ) in each sample to charIDToTypeID( "T " ); Note the charID's are four characters in length. After making that change I was able to set both the frame delay and loop count.

Could you see if that resolves your problem? If it doesn't could you provide a sample script and sample file that reproduces the problem (and provide the Photoshop version and OS/version as requested)?

Thanks,
Eric

Votes

Translate

Translate

Report

Report
Adobe Employee ,
Nov 17, 2014 Nov 17, 2014

Copy link to clipboard

Copied

It appears the forum removes spaces in posts, so the change I mentioned probably isn't the issue you are seeing. Please provide the Photoshop version and sample files, if possible.

Thanks,
Eric

Votes

Translate

Translate

Report

Report
LEGEND ,
Nov 18, 2014 Nov 18, 2014

Copy link to clipboard

Copied

Hi Eric, Hi Jeffrey,

There's a small mistake in Hannes's question. What we're trying to do is read those values ("animationFrameDelay" and "animationLoopCount"). Setting them through code recorded with the ScriptingListener works fine but I have found no way of reading them.

Is there any way (either through the public API or through ScriptingListener code) to do that?

We are using Photoshop CC 2014.2.1 (20141014.r.257 x64) on Windows 7

Votes

Translate

Translate

Report

Report
Adobe Employee ,
Nov 18, 2014 Nov 18, 2014

Copy link to clipboard

Copied

Thanks. I've updated the topic. We'll look at adding this to the DOM. It's not currently possible.

Votes

Translate

Translate

Report

Report
LEGEND ,
May 22, 2017 May 22, 2017

Copy link to clipboard

Copied

LATEST
I have a need to get the animation loop count and type (once, 3 times, forever, etc) as well.  This thread is 3 years old, any chance this has this been added to the DOM yet?

Edit: I got a working solution here:
https://forums.adobe.com/message/9530838#2318910

Votes

Translate

Translate

Report

Report