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

Javascript: Placing an Item with multiple artboards

Explorer ,
Dec 30, 2020 Dec 30, 2020

Is there a way to access the import options on a placed item?

 

if you place an ai file with multiple artboards you are allowed to choose which "page" is placed, but when using the javascript it defaults to the first page. Is there a way to access that? I have looked through the javascript guide, but havent found anything.

TOPICS
Scripting
346
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

correct answers 1 Correct answer

Community Expert , Dec 30, 2020 Dec 30, 2020
// place a specific Artboard from an ai doc

var idoc = app.activeDocument;

var pdfOptions = app.preferences.PDFFileOptions;
pdfOptions.pageToOpen = 4; // it works for Artboards since placing an ai file places the pdf version

var iplaced = idoc.placedItems.add();

iplaced.file = File( '/c/...full path.../your file.ai');
Translate
Adobe
Guide ,
Dec 30, 2020 Dec 30, 2020

My understanding is that artboards are not container objects; i.e. artboards do not contain items (e.g. placedItems). But you can position an item "on" an artboard; you just position the item in relation to the artboard in question.

 

var yourFile = new File(path);
var yourPic = app.activeDocument.placedItems.add();
yourPic.file = yourFile;

var AB = app.activeDocument.artboards[index];
// var AB = app.activeDocument.artboards.getByName(name);
yourPic.position = [AB.artboardRect[0], AB.artboardRect[1]];

 

Edit:  It seems I misunderstood the question. 

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 ,
Dec 30, 2020 Dec 30, 2020
LATEST
// place a specific Artboard from an ai doc

var idoc = app.activeDocument;

var pdfOptions = app.preferences.PDFFileOptions;
pdfOptions.pageToOpen = 4; // it works for Artboards since placing an ai file places the pdf version

var iplaced = idoc.placedItems.add();

iplaced.file = File( '/c/...full path.../your file.ai');
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