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

Reproduce "File > Place" in Illustrator via scripting

Community Beginner ,
Nov 08, 2019 Nov 08, 2019

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.

TOPICS
Scripting
1.1K
Translate
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
Advocate ,
Nov 08, 2019 Nov 08, 2019

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

Translate
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
Community Beginner ,
Nov 08, 2019 Nov 08, 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.

 

Screenshot 2019-11-08 at 16.04.58.png

Translate
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
Community Expert ,
Nov 08, 2019 Nov 08, 2019
LATEST

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

Translate
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