Skip to main content
Participant
November 8, 2019
Question

Reproduce "File > Place" in Illustrator via scripting

  • November 8, 2019
  • 2 replies
  • 1160 views

The only way that I've found to place an image via scripting in Illustrator is this:

var doc = app.activeDocument;
var placedItem = doc.placedItems.add();
placedItem.file = new File("image.jpg");

This though is different from the way you would trigger the "File > Place" command in Illustrator (or even InDesign), because you don't get to use the "gun placer" tool and decide where to place the image.

 

Is there a way to trigger the specific command in IL via JS scripting?

 

InDesign's has app.activeDocument.place() but I couldn't find anything similar in IL.

This topic has been closed for replies.

2 replies

CarlosCanto
Community Expert
Community Expert
November 8, 2019

no we don't have a way to trigger the place "gun". The place() function places the image in the middle of the screen, so would need to either move your screen so the image places in the right place or (the easiest) just move your image to the right place using left/top properties or position property

meganchi
Legend
November 8, 2019

Could you use the shortcut command for placing something instead (command + D on mac or control + D on windows)?

Participant
November 8, 2019

I think it's CMD + P on my Illustrator 2020 installation.

 

Nethertheless, I have a specific use case (I'm developing a CEP extension) and I wanted to replicate the Place command like it is in the UI.