Copy link to clipboard
Copied
Hi,
I have really tried but can't really understand the illustrator script guide.
I want to rename my selected layer with the name "copyfx" but what changes are all layers
what's wrong with this script?
//
var document = app.activeDocument;
var layers= document.layers;
for(var i =0; i < layers.length;i++) {
layers[i].name ="copyfx";
}
is there a way to solve it? thanks
Copy link to clipboard
Copied
The above script loops through all the layers and names each layer, as it is written to do.
Layers don't have a "selected" property, but they do have a "hasSelectedArtwork" property. One can add a conditional to test whether or not a layer "hasSelectedArtwork", limiting the naming to those layers which do.
var document = app.activeDocument;
var layers = document.layers;
for (var i = 0; i < layers.length; i++) {
if (layers[i].hasSelectedArtwork == true) {
layers[i].name = "copyfx";
}
}
Copy link to clipboard
Copied
this works, but what I mean is renaming the active sublayer, is there a workaround?
Copy link to clipboard
Copied
There are no sublayers in the image. There are layers and path items. This will name the active layer.
var document = app.activeDocument;
document.activeLayer.name = "copyfx";
Copy link to clipboard
Copied
is this script correct?
sorry I never code