Illustrator script: all Artboard Elements to Symbol

New Here ,
Apr 23, 2022 Apr 23, 2022

Copy link to clipboard

Copied

Hi,

I have been trying to make a simple script that selects all elements on an artboard and makes a symbol with the name of the artboard. Unfortunately the symbols.add(selection) does not work. Can anyone give me a clue or solution. 

TOPICS
Scripting

Views

90

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
Advisor ,
Apr 23, 2022 Apr 23, 2022

Copy link to clipboard

Copied

One can't debug code that one can't see. Also, it would be helpful to show what you're trying to achieve with a screenshot. 

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
Adobe Community Professional ,
Apr 23, 2022 Apr 23, 2022

Copy link to clipboard

Copied

LATEST

Hi,

You can try the following,

 

var doc = app.activeDocument;
var _activeAtboardName = doc.artboards[app.activeDocument.artboards.getActiveArtboardIndex()].name
doc.selectObjectsOnActiveArtboard();
app.executeMenuCommand('group');
var _symbol = doc.symbols.add(app.selection[0]);
_symbol.name = _activeAtboardName;
app.executeMenuCommand('ungroup');

 

app.selection, is an array, but symbols.add expect a single pageItem not an array, tehrefore, group all items before making symbol and after that ungroup it.

 

 

Best regards

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