Skip to main content
Participant
January 18, 2017
Answered

Is it possible to get the items on a specific artboard with script?

  • January 18, 2017
  • 1 reply
  • 1246 views

My document has several artboards and I want to get the items on a specific artboard with script as written in this title.

I read the following scripting reference but cannot find any methods to do that..
http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/pdf/illustrator/scripting/illustrator_scripting_reference_javascr…

I would like to know if it is possible and hopefully want to get the method or some sample codes.

Thanks!

This topic has been closed for replies.
Correct answer Silly-V

You can check for the bounds coordinates of your art and see if it fits within the coordinates of your artboard you want.

Or, you can activate your desired artboard and use the selectObjectsOnActiveArtboard() command to select all art on it and then cycle through that art to process the pieces you want. When using setActiveArtboardIndex as below, we use a 0-index based syntax, so for artboard #4, you have to put in a 3.

#target illustrator

function test(){

  var doc = app.activeDocument;

  doc.artboards.setActiveArtboardIndex(3);

  doc.selectObjectsOnActiveArtboard();

  var sel = doc.selection;

  alert("Your selection contains " + sel.length + " items.");

};

test();

1 reply

Silly-V
Silly-VCorrect answer
Legend
January 18, 2017

You can check for the bounds coordinates of your art and see if it fits within the coordinates of your artboard you want.

Or, you can activate your desired artboard and use the selectObjectsOnActiveArtboard() command to select all art on it and then cycle through that art to process the pieces you want. When using setActiveArtboardIndex as below, we use a 0-index based syntax, so for artboard #4, you have to put in a 3.

#target illustrator

function test(){

  var doc = app.activeDocument;

  doc.artboards.setActiveArtboardIndex(3);

  doc.selectObjectsOnActiveArtboard();

  var sel = doc.selection;

  alert("Your selection contains " + sel.length + " items.");

};

test();

Participating Frequently
January 18, 2017