Highlighted

Illustrator scripting problem

New Here ,
Apr 26, 2020

Copy link to clipboard

Copied

Hi all,

I have an illustrator scripting question that I am unable to find help on anywhere.

I have multiple layers with one or more items in each layer. Each layer has a meaninful name but the items within the layers do not(they are not sub-layers, they are items such as rectangles, lines etc.)

I need to rename the items in each layer with the same name as the parent layer. If there are multiple items within a layer, they all need the same name as the layer that they are a member of.

 

If anyone could point me towards anything that will do this I'd be really grateful.

Many thanks.

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

Hello, That can be done easily, First you need to traverse all layers present in the document and then, you traverse all pageItems inside the layers and assign name of the parent layer. Here is the small sample script that will help you to this.

 

var layers = app.activeDocument.layers;
for (var i = 0; i < layers.length; i++) {
    var layerName = layers[i].name;
    for (var j = 0; j < layers[i].pageItems.length; j++) {
        layers[i].pageItems[j].name = layerName;
    }
}

 

This script will not name the items that are inside the groups. Hope this helps you to start the script.

Topics

Scripting

Views

613

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

Illustrator scripting problem

New Here ,
Apr 26, 2020

Copy link to clipboard

Copied

Hi all,

I have an illustrator scripting question that I am unable to find help on anywhere.

I have multiple layers with one or more items in each layer. Each layer has a meaninful name but the items within the layers do not(they are not sub-layers, they are items such as rectangles, lines etc.)

I need to rename the items in each layer with the same name as the parent layer. If there are multiple items within a layer, they all need the same name as the layer that they are a member of.

 

If anyone could point me towards anything that will do this I'd be really grateful.

Many thanks.

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

Hello, That can be done easily, First you need to traverse all layers present in the document and then, you traverse all pageItems inside the layers and assign name of the parent layer. Here is the small sample script that will help you to this.

 

var layers = app.activeDocument.layers;
for (var i = 0; i < layers.length; i++) {
    var layerName = layers[i].name;
    for (var j = 0; j < layers[i].pageItems.length; j++) {
        layers[i].pageItems[j].name = layerName;
    }
}

 

This script will not name the items that are inside the groups. Hope this helps you to start the script.

Topics

Scripting

Views

614

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
Apr 26, 2020 0
Adobe Community Professional ,
Apr 26, 2020

Copy link to clipboard

Copied

Hello, That can be done easily, First you need to traverse all layers present in the document and then, you traverse all pageItems inside the layers and assign name of the parent layer. Here is the small sample script that will help you to this.

 

var layers = app.activeDocument.layers;
for (var i = 0; i < layers.length; i++) {
    var layerName = layers[i].name;
    for (var j = 0; j < layers[i].pageItems.length; j++) {
        layers[i].pageItems[j].name = layerName;
    }
}

 

This script will not name the items that are inside the groups. Hope this helps you to start the script.

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
Reply
Loading...
Apr 26, 2020 2
New Here ,
Apr 26, 2020

Copy link to clipboard

Copied

Wow that is awesome, thank you so much!!  Are you on peopleperhour or similar?

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
Reply
Loading...
Apr 26, 2020 0
Adobe Community Professional ,
Apr 26, 2020

Copy link to clipboard

Copied

Your welcome 🙂 DM you.

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
Reply
Loading...
Apr 26, 2020 0