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

JS ActionExecute ignores changes to ActionDescriptor

New Here ,
Aug 07, 2009 Aug 07, 2009

I am trying to iterate a changing effect over a series of files. Emboss for example. The effect works fine if I run the script once with a single set of settings in the effect.

var idEmbs = charIDToTypeID( "Embs" );

    var desc1 = new ActionDescriptor();

    var idAngl = charIDToTypeID( "Angl" );

    desc1.putInteger( idAngl, 135 );

    var idHght = charIDToTypeID( "Hght" );

    desc1.putInteger( idHght, 3 );

    var idAmnt = charIDToTypeID( "Amnt" );

    desc1.putInteger( idAmnt, 144 );

alert("Angle is: "+desc1.getInteger(idAngl));     // I put this alert to see if the descriptor is updating properly

executeAction( idEmbs, desc1, DialogModes.NO );

I run the script. Close the file and all is well.

But! If I change the settings in the descriptor definition above (for instance change the Angle to 30:

    desc1.putInteger( idAngl, 30 );

) and then run the script again on an identical file the effect does not change. The effect still has an angle of 135. The descriptor is being changed properly (the alert on the second to last line reads 30 from the descriptor instead of 135 as before), but it appears that executeAction is not actually using the new descriptor.

If I quit and reopen photoshop and then run the script the effect works properly with an angle of 30 but then I'm stuck there -- I can't change it back to 135 without restarting photoshop. I've tried dropping, clearing, and reassigning the descriptor at various points in the script, messed with the variable scope (inside and outside of functions, global, local), but nothing seems to work. This is the first PS scripting I've done -- is there something I'm missing? Does PS scripting pre-compile commands or something?

I would really appreciate any help. I've combed the forums and tried everything I can think of with no luck.

I'm on CS4 11.0.1, MacOS 10.5.6

Thanks,

-Natan

TOPICS
Actions and scripting
980
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
Adobe
Guru ,
Aug 08, 2009 Aug 08, 2009

I know it's not any help, but changing the values work for me. CS4, WinXP

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
New Here ,
Aug 09, 2009 Aug 09, 2009

Thanks Michael. It helps to know that I'm not missing something conceptual.

I will try on a different machine and post my results.

I wonder if it could be a Mac-specific bug (though it's probably too early to start doubting Adobe).

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
Advisor ,
Aug 09, 2009 Aug 09, 2009

It's not a Mac problem. OSX 10.5.7, CS4.

executeAction returns an ActionDescriptor. You may want to inspect what's in there.

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
New Here ,
Aug 11, 2009 Aug 11, 2009

Thanks xbytor2.

Looking at the descriptor returned by ActionExecute shows the actual transform that happened, which differs from what I try to change it to. I've tried with a few effects and it happens whenever I use ActionExecute. Here I'm using color halftone. When I run this the first alert in the code below returns a radius of 8 the second returns the value it had at the first run. In other words they are the same only the first time this is run after PS is restarted.  I've pasted my full code below.

// enable double clicking from the Macintosh Finder or the Windows Explorer

#target photoshop

// in case we double clicked the file

app.bringToFront();

//Here's the folder containing the images we'll need to modify

var folderPath = "/Users/nd/images/";

var fileRef = new File(folderPath+"Comp 1 001.psd");

docRef = open (fileRef);

app.activeDocument.changeMode(ChangeMode.GRAYSCALE);  // change to grayscale

docRef.activeLayer.applyGaussianBlur(3);

var idClrH = charIDToTypeID( "ClrH" );

var desc2 = new ActionDescriptor();

desc2.clear();

var idRds = charIDToTypeID( "Rds " );

desc2.putInteger( idRds, 8 );

var idAngone = charIDToTypeID( "Ang1" );

desc2.putInteger( idAngone, 45 );

var idAngtwo = charIDToTypeID( "Ang2" );

desc2.putInteger( idAngtwo, 45 );

var idAngthree = charIDToTypeID( "Ang3" );

desc2.putInteger( idAngthree, 45 );

var idAngfour = charIDToTypeID( "Ang4" );

desc2.putInteger( idAngfour, 45 );

alert("Radius is: "+desc2.getInteger(idRds))

var executedDesc = executeAction( idClrH, desc2, DialogModes.NO );

alert("Executed Radius is: "+executedDesc.getInteger(idRds))

delete desc2;

fileRef = null;

Any help is truly appreciated. I've tried this on two machines, one 10.5.5 and one 10.5.8 and on CS3 and CS4 with the same result so I guess there's something wrong with the code.

Thanks again.

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
Guru ,
Aug 11, 2009 Aug 11, 2009
LATEST

Strange, I have only checked the descriptor when DialogModes is set to ALL to get the user's settings.

It seems that when DialogModes is not set to ALL the returned descriptor is not accurate. However the new values are being used ( at least in my test of your code ). For example if I make a big change, say change the radius from 8 to 48 I can clearly see that the new values are used even though the alert doesn't show the new value.

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