Symbol names in the Illustrator

AiScripts
2 min readNov 22, 2021

--

When you create a symbol, Illustrator requires you to enter its name, even if it is a space. The user can give different names to copies of the parent symbol in the Layers panel.

To get the name of a symbol, you need to refer to it by its index activeDocument.symbols[index].name in the Symbols panel. But this is the name of the parent symbol, not the current copy in the Layers panel. To do this, we first take the PageItems of the document and address its name through the activeDocument.pageItems[index].symbol.name .

And now the surprise: if the symbol instance is manually renamed, its actual name is already stored in activeDocument.pageItems[index].name . The previous construction will show the original name.

So we need to check both the object type and the name string. Below is an example of getting the name of the selected object.

var item = activeDocument.selection[0];
var itemName = '';
if (item.typename === 'SymbolItem' && item.name == '') {
itemName = item.symbol.name;
} else {
itemName = item.name;
}

--

--

AiScripts
AiScripts

Written by AiScripts

Sergey Osokin. Product Illustrator, Icon Designer, Script Developer (Ai, Ps). Writing about bugs and tricks in Adobe Illustrator scripts

No responses yet