Lagging object renaming

Nov 8, 2021


The name property contains the name of the objects in Illustrator, which is displayed in the Layers panel. To rename a selected object, just use this construction:

selection[0].name = "square";

In Illustrator older than CC 2020 we are in for a surprise, the new name will not appear in the Layers panel until we reset the selection or select another object.

The new name is displayed only after the action

A quick way to see the new name and keep the object selected is to add an empty path after the name is assigned and remove it immediately.

var tmp = app.selection[0].layer.pathItems.add();
The new name of the selected object immediately appears in the Layers panel

If you change the name of an unselected object, you can use another way — after setting the name, change the visibility of the object’s layer. = "New";
path.layer.visible = false;
path.layer.visible = true;




Sergey Osokin. I’m a illustrator & Script Developer (Ai, Ps). Writing about bugs and tricks.