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;
}