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

Problem with jsxbin and dollar ($) object

New Here ,
Oct 28, 2008 Oct 28, 2008

Copy link to clipboard

Copied

Hello all. I'm developing a script for Photoshop CS3 that exports the layers of a psd to a readable format for my company's 3D application, and everything has gone well until now that I need to convert the .js to .jsxbin so no one can see the code (well, I know it wouldn't be difficult to hack that).

The problem is this: imagine that my script's name is "myscript.js" and it has a directory "myscript" with some files I need during the exporting process (mostly images that I put in the dialog). When I was executing it as a .js, the path of the "scripts" folder was easily found this way:

var path = $.fileName.substring (0, indexOf(".")) + "/";

This returns "C:/<<adobe photoshop scripts path>>/myplugin/".

However, when I use ExtendScript to export it as binary, that line returns an empty string, like it didn't recognize the dollar ($) object. What I've tried after that is this:

var path = Folder.current + "/myplugin/";

This returns the same path but, again, only when executing the script as a .js. If I export it to jsxbin, the Folder.current is not being searched when running the script (which should be the correct thing) but is saved in the binary conversion, so it saves the path of my workspace and that's what is always shown from wherever I execute it (another directory, another machine). I hope I explained well this last step (if not, please advice).

Is there a way to solve this problem? I've run out of ideas 😞

Thanks beforehand.
TOPICS
Actions and scripting

Views

917

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
Adobe
Valorous Hero ,
Oct 28, 2008 Oct 28, 2008

Copy link to clipboard

Copied

You could try this..

alert(whereAmI());
function whereAmI(){
var where
try {
app.documents.test();
}
catch (err){
where = File(err.fileName);
}
return where.path;
}

Votes

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
Explorer ,
Oct 28, 2008 Oct 28, 2008

Copy link to clipboard

Copied

There are some things (including $.fileName) that just do not work in jsxbin's.
I don't thing the exception hook will work either.

Either use an ini file in a well known location (~/Desktop) or make sure your
files are put in Presets/Scripts. That location can be determined with this bit
of code:

var SCRIPTS_FOLDER =
new Folder(app.path + '/' +
localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts"));


-X

Votes

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
Valorous Hero ,
Oct 28, 2008 Oct 28, 2008

Copy link to clipboard

Copied

Tested it with Photoshop CS4 and it worked does not work in CS3.

Votes

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
Explorer ,
Oct 28, 2008 Oct 28, 2008

Copy link to clipboard

Copied

Paul_R@adobeforums.com wrote:
> Tested it with Photoshop CS4 and it worked does not work in CS3.

I should say 'That's a surprise'. The question should now be 'What is the
intended/correct behavior?'. There is so little said anywhere about jsxbin that
it's still a black box that I'd prefer not to play with lest something go "BOOM!".

-X

Votes

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
New Here ,
Oct 29, 2008 Oct 29, 2008

Copy link to clipboard

Copied

LATEST
"var SCRIPTS_FOLDER =
new Folder(app.path + '/' +
localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts"));"

That one worked perfectly. Thank you very very much :D

Votes

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