ActionToJavascript on Mac with CS5.5

Discussion of the xtools Toolkit

Moderators: xbytor, DavideBarranca, Paul MR

pierrelabbe

ActionToJavascript on Mac with CS5.5

Postby pierrelabbe » Mon Jan 23, 2012 9:28 am

Hi,
I can not get a correct result (see below) with ActionToJavaScript script (version 1.8 of Xtools). The JSX file is empty or nearly achieved.
What to add or change for this to work correctly with version CS5.5 (or CS5 Photoshop)?
Code: Select all#target photoshop
//
// TEST.jsx
//

//
// Generated Mon Jan 23 2012 10:18:59 GMT+0100
//

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

//
//====================  ==============
//
function () {
};



//=========================================
//                    essai.main
//=========================================
//

essai.main = function () {
  ();
};

essai.main();

// EOF

"TEST.jsx"
// EOF

xbytor

ActionToJavascript on Mac with CS5.5

Postby xbytor » Mon Jan 23, 2012 3:38 pm

ActionToJavascript has worked on all versions of PS for several years. While there are some things that you can do in PS that it cannot handle, it is rare that it generates no code at all. Perhaps it would help if you sent me a .atn file with this troublesome Action and I'll see if I can sort out what's going on.

pierrelabbe

ActionToJavascript on Mac with CS5.5

Postby pierrelabbe » Mon Jan 23, 2012 6:02 pm

The script works with CS4 but not CS5.
With CS4, I sometimes have a message indicating that the file already exists in "private:var ..."

xbytor

ActionToJavascript on Mac with CS5.5

Postby xbytor » Mon Jan 23, 2012 6:45 pm

It works with CS5. I had too much problems with CS5, CS5.5 and the CS6 beta on my machine all at the same time so I can't test with CS5.5. However, there shouldn't be a difference between the two revs.

You may want to download the most recent version from CVS on sourceforge:
http://ps-scripts.cvs.sourceforge.net/v ... script.jsx ... script.jsx

I push updates out there on occasion and may have fixed problems with this script in CS5 after I uploaded the last zip file.

I have not tested this with a non-English version of PS in a long time. If the current version does not work and you are using
a localized version of PS, let me know what your PS locale is and I'll see if I can get it fixed.

Here's the output I got:

Code: Select all#target photoshop
//
// radial.jsx
//

//
// Generated Mon Jan 23 2012 12:27:59 GMT-0600
//

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

//
//==================== radial ==============
//
function radial() {
  // Make
  function step1(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putClass(sTID("contentLayer"));
    desc1.putReference(cTID('null'), ref1);
    var desc2 = new ActionDescriptor();
    var desc3 = new ActionDescriptor();
    desc3.putBoolean(cTID('Rvrs'), true);
    desc3.putUnitDouble(cTID('Angl'), cTID('#Ang'), 90);
    desc3.putEnumerated(cTID('Type'), cTID('GrdT'), cTID('Rdl '));
    var desc4 = new ActionDescriptor();
    desc4.putString(cTID('Nm  '), "$$$/DefaultGradient/BlackWhite=Black, White");
    desc4.putEnumerated(cTID('GrdF'), cTID('GrdF'), cTID('CstS'));
    desc4.putDouble(cTID('Intr'), 4096);
    var list1 = new ActionList();
    var desc5 = new ActionDescriptor();
    var desc6 = new ActionDescriptor();
    desc6.putDouble(cTID('Rd  '), 23.9408490434289);
    desc6.putDouble(cTID('Grn '), 24.5814661681652);
    desc6.putDouble(cTID('Bl  '), 23.742514885962);
    desc5.putObject(cTID('Clr '), sTID("RGBColor"), desc6);
    desc5.putEnumerated(cTID('Type'), cTID('Clry'), cTID('UsrS'));
    desc5.putInteger(cTID('Lctn'), 0);
    desc5.putInteger(cTID('Mdpn'), 50);
    list1.putObject(cTID('Clrt'), desc5);
    var desc7 = new ActionDescriptor();
    var desc8 = new ActionDescriptor();
    desc8.putDouble(cTID('Rd  '), 255);
    desc8.putDouble(cTID('Grn '), 255);
    desc8.putDouble(cTID('Bl  '), 255);
    desc7.putObject(cTID('Clr '), sTID("RGBColor"), desc8);
    desc7.putEnumerated(cTID('Type'), cTID('Clry'), cTID('UsrS'));
    desc7.putInteger(cTID('Lctn'), 4096);
    desc7.putInteger(cTID('Mdpn'), 50);
    list1.putObject(cTID('Clrt'), desc7);
    desc4.putList(cTID('Clrs'), list1);
    var list2 = new ActionList();
    var desc9 = new ActionDescriptor();
    desc9.putUnitDouble(cTID('Opct'), cTID('#Prc'), 100);
    desc9.putInteger(cTID('Lctn'), 0);
    desc9.putInteger(cTID('Mdpn'), 50);
    list2.putObject(cTID('TrnS'), desc9);
    var desc10 = new ActionDescriptor();
    desc10.putUnitDouble(cTID('Opct'), cTID('#Prc'), 100);
    desc10.putInteger(cTID('Lctn'), 4096);
    desc10.putInteger(cTID('Mdpn'), 50);
    list2.putObject(cTID('TrnS'), desc10);
    desc4.putList(cTID('Trns'), list2);
    desc3.putObject(cTID('Grad'), cTID('Grdn'), desc4);
    desc2.putObject(cTID('Type'), sTID("gradientLayer"), desc3);
    desc1.putObject(cTID('Usng'), sTID("contentLayer"), desc2);
    executeAction(cTID('Mk  '), desc1, dialogMode);
  };

  // Move
  function step2(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
    desc1.putReference(cTID('null'), ref1);
    var ref2 = new ActionReference();
    ref2.putIndex(cTID('Lyr '), 0);
    desc1.putReference(cTID('T   '), ref2);
    desc1.putBoolean(cTID('Adjs'), false);
    executeAction(cTID('move'), desc1, dialogMode);
  };

  // Set
  function step3(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(sTID("contentLayer"), cTID('Ordn'), cTID('Trgt'));
    desc1.putReference(cTID('null'), ref1);
    var desc2 = new ActionDescriptor();
    desc2.putBoolean(cTID('Rvrs'), true);
    desc2.putUnitDouble(cTID('Angl'), cTID('#Ang'), 90);
    desc2.putEnumerated(cTID('Type'), cTID('GrdT'), cTID('Rdl '));
    desc2.putUnitDouble(cTID('Scl '), cTID('#Prc'), 90);
    var desc3 = new ActionDescriptor();
    desc3.putString(cTID('Nm  '), "$$$/DefaultGradient/BlackWhite=Black, White");
    desc3.putEnumerated(cTID('GrdF'), cTID('GrdF'), cTID('CstS'));
    desc3.putDouble(cTID('Intr'), 4096);
    var list1 = new ActionList();
    var desc4 = new ActionDescriptor();
    var desc5 = new ActionDescriptor();
    desc5.putDouble(cTID('Rd  '), 23.9408490434289);
    desc5.putDouble(cTID('Grn '), 24.5814661681652);
    desc5.putDouble(cTID('Bl  '), 23.742514885962);
    desc4.putObject(cTID('Clr '), sTID("RGBColor"), desc5);
    desc4.putEnumerated(cTID('Type'), cTID('Clry'), cTID('UsrS'));
    desc4.putInteger(cTID('Lctn'), 0);
    desc4.putInteger(cTID('Mdpn'), 50);
    list1.putObject(cTID('Clrt'), desc4);
    var desc6 = new ActionDescriptor();
    var desc7 = new ActionDescriptor();
    desc7.putDouble(cTID('Rd  '), 255);
    desc7.putDouble(cTID('Grn '), 255);
    desc7.putDouble(cTID('Bl  '), 255);
    desc6.putObject(cTID('Clr '), sTID("RGBColor"), desc7);
    desc6.putEnumerated(cTID('Type'), cTID('Clry'), cTID('UsrS'));
    desc6.putInteger(cTID('Lctn'), 4096);
    desc6.putInteger(cTID('Mdpn'), 50);
    list1.putObject(cTID('Clrt'), desc6);
    desc3.putList(cTID('Clrs'), list1);
    var list2 = new ActionList();
    var desc8 = new ActionDescriptor();
    desc8.putUnitDouble(cTID('Opct'), cTID('#Prc'), 100);
    desc8.putInteger(cTID('Lctn'), 0);
    desc8.putInteger(cTID('Mdpn'), 50);
    list2.putObject(cTID('TrnS'), desc8);
    var desc9 = new ActionDescriptor();
    desc9.putUnitDouble(cTID('Opct'), cTID('#Prc'), 100);
    desc9.putInteger(cTID('Lctn'), 4096);
    desc9.putInteger(cTID('Mdpn'), 50);
    list2.putObject(cTID('TrnS'), desc9);
    desc3.putList(cTID('Trns'), list2);
    desc2.putObject(cTID('Grad'), cTID('Grdn'), desc3);
    desc1.putObject(cTID('T   '), sTID("gradientLayer"), desc2);
    executeAction(cTID('setd'), desc1, dialogMode);
  };

  step1();      // Make
  step2();      // Move
  step3();      // Set
};



//=========================================
//                    radial.main
//=========================================
//

radial.main = function () {
  radial();
};

radial.main();

// EOF

"radial.jsx"
// EOF


pierrelabbe

ActionToJavascript on Mac with CS5.5

Postby pierrelabbe » Mon Jan 23, 2012 7:13 pm

Thanks, I get better results with the latest version of your script, with some actions (which loads a file JSX), I have an error message (see attachment).
I work on Mac (10.6., with French version of CS5.5 (I also installed a beta version CS6 but the script does not already operating prior to installation).

xbytor

ActionToJavascript on Mac with CS5.5

Postby xbytor » Mon Jan 23, 2012 11:46 pm

The error is happening when the script is trying to generate code for an action step that calls a script. For some reason, it was not able to correctly determine the path to the script from the .atn file. This can happen when you try to do the conversion on a PC when it was recorded on a Mac (or vice versa). Also, the format for paths in .atn files has changed between PS versions. If it sees a problem, it should give you a warning and use "~/Desktop" as the path to the script. Unfortunately, "~/Desktop" may not be correct for the French version of whatever OS your using. Let me
know. It's a relatively fix.

Can you send me an action that contains a single step? Just have it run a script. I'll see if I can replicate the error on one of my machines.

xbytor

ActionToJavascript on Mac with CS5.5

Postby xbytor » Tue Jan 24, 2012 12:12 am

It looks like "~/Desktop" is "~/Bureau" in the French version of Windows so it looks like that may be the problem.

I've fixed that and updated the necessary files on sourceforge. Download the new rev and see if it works.

One more thing: Whenever you translate an Action that contains calls to scripts, it's usually best to go in and verify or change the paths to the scripts.

pierrelabbe

ActionToJavascript on Mac with CS5.5

Postby pierrelabbe » Tue Jan 24, 2012 2:09 pm

Hi,
Here is a .atn file that contains an action that calls a jsx script (see attachment). My jsx file is in the folder of scripts of Photoshop (Presets/Scripts).

xbytor

ActionToJavascript on Mac with CS5.5

Postby xbytor » Tue Jan 24, 2012 6:40 pm

I found the problem. Either PS changed the way Filter->Automate->Scripts invocations are encoded or I just never dealt with them correctly.
In either case, I've added support to handle both encodings. The revisions are now on sourceforge.

Let me know if this works out for you.

BTW, there was a problem with TEST2.atn file you uploaded. The name of the script was not actually there.

pierrelabbe

ActionToJavascript on Mac with CS5.5

Postby pierrelabbe » Tue Jan 24, 2012 6:44 pm

xbytor wrote: The revisions are now on sourceforge
Please. Where are they exactly on sourceforge? What is URL?


Return to “xtools”

Who is online

Users browsing this forum: No registered users and 8 guests