• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Illustrator scripting problem

Community Beginner ,
Apr 26, 2020 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.

TOPICS
Scripting

Views

856

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
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 26, 2020 Apr 26, 2020

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

...

Votes

Translate

Translate
Adobe
Community Expert ,
Apr 26, 2020 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

Votes

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
community guidelines
Community Beginner ,
Apr 26, 2020 Apr 26, 2020

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Community Expert ,
Apr 26, 2020 Apr 26, 2020

Copy link to clipboard

Copied

LATEST

Your welcome 🙂 DM you.

Best regards

Votes

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
community guidelines