Selection objects from the arboard in an illustrator script

Explorer ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

Hello everyone!

 

I am importing PDFs to illustrator using a script, and up until now I have been embedding the PDF as a groupItem. I have only been importing PDFs with one group of items to apply effects to, so everything has worked fine until now.

 

However, now I want to import PDFs with two or three groupItems. I have been trying to select these by iterating through all the groupItem elements in the document, but I many more than the three I want to select (I get over 20).

This is my document, and there are three designs which occupy a third of the document each:

Screenshot 2021-01-15 124759.png

 

Any ideas how I can go about selecting these three designs and applying effects to them individually?

 

Thank you!

TOPICS
Scripting

Views

111

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
community guidelines

correct answers 1 Correct Answer

Enthusiast , Jan 15, 2021 Jan 15, 2021
Further to what @CarlosCanto said ...// referencing items on artboard var list = ""; for (var i = 0; i < activeDocument.artboards.length; i++) { activeDocument.artboards.setActiveArtboardIndex(i); activeDocument.selectObjectsOnActiveArtboard(); for (var j = 0; j < selection.length; j++) { list = list + activeDocument.artboards[i].name + " - " + selection[j].name + "\r"; } } alert( list );

Likes

Translate

Translate
Adobe Community Professional ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

we can select everything in a given artboard. We have to activate the target artboard first

 

 

activeDocument.artboards.setActiveArtboardIndex(1); // activate 2nd artboard
activeDocument.selectObjectsOnActiveArtboard(); // select all in active artboard

 

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
community guidelines
Enthusiast ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

LATEST

Further to what @CarlosCanto said ...

// referencing items on artboard
var list = "";
for (var i = 0; i < activeDocument.artboards.length; i++) {
    activeDocument.artboards.setActiveArtboardIndex(i);
    activeDocument.selectObjectsOnActiveArtboard();
    for (var j = 0; j < selection.length; j++) {
        list = list + activeDocument.artboards[i].name + " - " + selection[j].name + "\r";
    }
}
alert( list );

 

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
community guidelines