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

Batch Change Sub Layer Names with Top Layer Names

Participant ,
Feb 19, 2019 Feb 19, 2019

Hello,

I have two questions,

First Question;

In order to export illustrator files to software such as Cinema 4D with correct layer structure and name , there should only be the lowest sub layer (one path) but with the top layer's name. I could not find an exact script to do that. I have 1000 layers like this.

question_2.png

Second Question;I want to copy and paste the names of top layers for all layers.

question_1.png

Please help, I could not find an exact script to do that.

Thank you,

Best Regards.

TOPICS
Scripting
1.2K
Translate
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
Adobe
Valorous Hero ,
Feb 19, 2019 Feb 19, 2019

Try this and see if it works:

#target illustrator

function test(){

  var doc = app.activeDocument;

  var topLayers = doc.layers;

  var thisTopLayer, thisSubLayer, thisPath;

  for (var i = 0; i < topLayers.length; i++) {

    thisTopLayer = topLayers[i];

    thisSubLayer = thisTopLayer.layers[0];

    thisPath = thisSubLayer.pathItems[0];

    thisPath.name = thisTopLayer.name;

  }

}

test();

Translate
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
Participant ,
Feb 19, 2019 Feb 19, 2019

Thanks a lot for the quick reply, it throws an error on this line. Also is it possible to extract lowest path to a new layer and delete empty like in my first question.

example.png

Translate
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
Valorous Hero ,
Feb 19, 2019 Feb 19, 2019

I looks like your structure is like this from the screenshot:

Top Layer > Sub-Layer > Path

Could one of your layers have this structure?

Top Layer > Group > Path

Translate
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
Advocate ,
Feb 24, 2019 Feb 24, 2019
LATEST

Bonjour,

// JavaScript Document

function test(){

  var doc = app.activeDocument;

  var topLayers = doc.layers;

  var thisTopLayer, thisSubLayer, thisPath;

  for (var i = 0; i < topLayers.length; i++) {

    thisTopLayer = topLayers;

    thisSubLayer = thisTopLayer.layers[0];

    thisPath = thisSubLayer.pathItems[0];

    thisPath.name = thisTopLayer.name;

    thisPath.move(thisTopLayer,ElementPlacement.PLACEATEND);

    thisSubLayer.remove();

  }

}

test();

DE LR

Translate
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