Highlighted

Scripting Illustrator using AppleScript - how to place a PDF file in a specific position and layer

New Here ,
Mar 14, 2020

Copy link to clipboard

Copied

Hello -

 

I am trying to automate my image creation pipeline and would like to program up the equivalent of paste (and scale) in illustrator. I am a newbie to scripting, but chose to use AppleScript, and I find the documentation far too sparse to be helpful.

 

My understanding is that I should be able to do this using either group item or placed item. However, if I try

 

set imageRef to make new placed item in imageLayer with properties {file path: imageFileName}

 

where imageLayer is defined using

 

set imageFileName to POSIX file "testFile.pdf"

 

while imageLayer is defined via

 

set imageLayer to layer 1 of docRef

 

However, when I try to execute the script, I get the following error message: "Adobe Illustrator got an error: Can’t make some data into the expected type."

 

Any advice would be very much appreciated! Also, if anyone could point me to the reference to the property fields of different objects, then that would also be very helpful (for example, where can I find the property fields for placed items or group items?

 

Thanks,

 

Carl

TOPICS
Scripting

Views

114

Likes

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

Scripting Illustrator using AppleScript - how to place a PDF file in a specific position and layer

New Here ,
Mar 14, 2020

Copy link to clipboard

Copied

Hello -

 

I am trying to automate my image creation pipeline and would like to program up the equivalent of paste (and scale) in illustrator. I am a newbie to scripting, but chose to use AppleScript, and I find the documentation far too sparse to be helpful.

 

My understanding is that I should be able to do this using either group item or placed item. However, if I try

 

set imageRef to make new placed item in imageLayer with properties {file path: imageFileName}

 

where imageLayer is defined using

 

set imageFileName to POSIX file "testFile.pdf"

 

while imageLayer is defined via

 

set imageLayer to layer 1 of docRef

 

However, when I try to execute the script, I get the following error message: "Adobe Illustrator got an error: Can’t make some data into the expected type."

 

Any advice would be very much appreciated! Also, if anyone could point me to the reference to the property fields of different objects, then that would also be very helpful (for example, where can I find the property fields for placed items or group items?

 

Thanks,

 

Carl

TOPICS
Scripting

Views

115

Likes

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
Mar 14, 2020 0
Explorer ,
Mar 17, 2020

Copy link to clipboard

Copied

1. File paths must be absolute, e.g. "/Users/carl/testFile.pdf"

 

2. If you’re on AI 2020, the file path must be given as a string:

        set imageFileName to "/Users/carl/testFile.pdf"

   For earlier versions, it must be a file object:

        set imageFileName to POSIX file "/Users/carl/testFile.pdf"

 

3. To view an application’s AppleScript dictionary in Script Editor, choose File > Open Dictionary. PDF-based documentation  (same info, but also includes example scripts) is also available at: www.adobe.com/devnet/illustrator/scripting.html

Likes

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
Reply
Loading...
Mar 17, 2020 0
AndyC8 LATEST
New Here ,
Jun 28, 2020

Copy link to clipboard

Copied

Hi Carl

 

Did you get this to work as I need to automate placing an image in illustrator as well.

 

AndyC

Likes

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
Reply
Loading...
Jun 28, 2020 0