Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Passing POSIX file path to Adobe Illustrator to run ExtendScrip

Here's the code snippet I started with

tell application "Adobe Illustrator"

activate

delay 10

set pfilepath to"/Users/username/Documents/Temp/someFile.ai"

set pfile to POSIX file pfilepath

open pfile as alias without options

delay 10

do javascript "#include '/Users/username/Documents/Temp/someScript.jsx'"

delay 1

quit

endtell


activate, open, quit, and "do javascript" commands are from/for Adobe Illustrator AppleScript API.


I originally ran the snippet through Python interface to Applescript and that didn't produce any error statements to debug, so I then executed directly from Applescript editor.


I'm using Mac OS X 10.9.5 with Adobe Illustrator CS6. The Applescript reference for Illustator CS6 should be this:


http://wwwimages.adobe.com/content/dam/ … Script.pdf


http://wwwimages.adobe.com/content/dam/ … -Guide.pdf


Does the code & syntax look correct, or what might I be doing wrong? Because the script is not currently working. I get error about can't get POSIX file. Tweaking code yesterday, with help of someone online in another discussion forum, I get other related errors, but as that discussion got deleted, I don't recall the exact tweaks and errors, but suffice to say, tweaks didn't help.


I personally am not familiar with Applescript. I know & prefer Windows COM API.

Posted on Mar 24, 2015 1:50 PM

Reply
5 replies

Mar 24, 2015 4:41 PM in response to daluu

Hello


Try replacing the following part:


set pfilepath to "/Users/username/Documents/Temp/someFile.ai" set pfile to POSIX file pfilepath open pfile as alias without options



with:


set pfilepath to "/Users/username/Documents/Temp/someFile.ai" open POSIX file pfilepath as alias




* According to the Illustrator-Scripting-Reference-AppleScript.pdf, open command has "with options ..." parameter but neither "without options" nor "options boolean".


* "open POSIX file posix_path as alias" is borrowed from p.288 of the Illustrator-Scripting-Reference-AppleScript.pdf.



Good luck,

H

Mar 25, 2015 11:52 AM in response to daluu

Thanks for the comments. I cross posted in MacScripter and this ended up working:

set pfilepath to POSIX path of (path to documents folder) & "Temp/test.png"

set pfile to POSIX file pfilepath as text

...

open file pfile without options

and this was the reasoning given: POSIX file returns a file URL. AI and PS aren't able to recognize this type. The solution is to coerce file URL to text (HFS path)

Mar 26, 2015 12:06 PM in response to Hiroto

I would think so too. Wonder how receptive Adobe is to updating their docs.


Either very few people use the Adobe Applescript API, or had to call the file open capabilities for it, or they use HFS rather than POSIX paths. Or they found problem and figured out solution anyhow. Because otherwise, this would have been found/known much sooner I'd think.

Passing POSIX file path to Adobe Illustrator to run ExtendScrip

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.