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

Is there a script to change layer colors within the layers palette in illustrator CS5?

Community Beginner ,
Apr 03, 2012 Apr 03, 2012

For example I would like to make my images layer Green and my copy layer Red in my layers palette.

TOPICS
Scripting
4.5K
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
Guru ,
Apr 03, 2012 Apr 03, 2012

The RGB selected highlight colors?

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
Community Beginner ,
Apr 03, 2012 Apr 03, 2012

In the layers palette whne you create multiple layers each layer is assigned a color by default. I'm looking to change the color for each layer using script. See attched screen grab. I want to change the colors of the layers within the layers palette.Screen shot 2012-04-03 at 3.03.04 PM.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
Guru ,
Apr 03, 2012 Apr 03, 2012

If you have a doc open then you can do this… It will look for a layer by name but you can change that to index or whatever…

#target illustrator

var doc = app.activeDocument;

var lay, layCol;

try {

          lay = doc.layers.getByName( 'Copy' );

          layCol = new RGBColor();

          layCol.red = 255;

          layCol.green = 0;

          layCol.blue = 255;

          lay.color = layCol

} catch (e) {};

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
Community Beginner ,
Apr 03, 2012 Apr 03, 2012

Thanks much. Appreciate your help

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
Community Beginner ,
Apr 03, 2012 Apr 03, 2012

Actually one more question. There is a drop down menu that contains pre loaded colors. These colors have specific names. Is there a way to change them to the colors within the drop down menu instead of assinging a generic RGB color?

Thanks

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
Guru ,
Apr 03, 2012 Apr 03, 2012

Im not sure but don't think so… Think they will all be 'other' no matter what the values… ID does have enumerators for it's UI colors but no such luck here…

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
Community Beginner ,
Dec 21, 2016 Dec 21, 2016

Thanks much helpful. Pls let me know how to change its sub layers color too.

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
Engaged ,
Dec 22, 2016 Dec 22, 2016

A recursive call a function.

New

Something like this:

//@target illustrator

(function recolLays(lays) {

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

    if (lays.layers.length) recolLays(lays.layers);

    lays.color = _getRandRgb();

  }

  function _getRandRgb() {

    var rgbCol   = new RGBColor();

    rgbCol.red   = __randInt(0, 255);

    rgbCol.green = __randInt(0, 255);

    rgbCol.blue  = __randInt(0, 255);

    return rgbCol;

    function __randInt(min, max) {

      var rand = min + Math.random() * (max + 1 - min);

      rand     = Math.floor(rand);

      return rand;

    }

  }

}(activeDocument.layers));

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
Community Beginner ,
Dec 28, 2016 Dec 28, 2016

But after breaking symbols am running this script but this doesn't works over there.

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
Engaged ,
Dec 28, 2016 Dec 28, 2016

Hmm, now I'm executed the script after breaking symbols – it works in CS5. What exactly isn't working?

New

before_recolor_layers.pngafter_recolor_script.png

Updated

But this is only an example of recursion. And what exactly do you want, I do not know.

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
Community Beginner ,
Jan 02, 2017 Jan 02, 2017

Yeah am working in CC 2017. The layer color was changed using this script buut its sublayers colors doesnt.

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
Engaged ,
Jan 02, 2017 Jan 02, 2017
LATEST

Give me your .ai-files where this doesn't working. What your OS? Are you use my unmodified version of script from this post ​?

I'm tested it in cc 2017 - with multiple (and multiple and multiple...) sub-layers ... all layers and sublayers recolored by script. I'm don't know why you have a problem with.

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