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

New Here ,
Apr 03, 2012 Apr 03, 2012

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

3.3K

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

Copy link to clipboard

Copied

The RGB selected highlight colors?

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
community guidelines
New Here ,
Apr 03, 2012 Apr 03, 2012

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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) {};

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
community guidelines
New Here ,
Apr 03, 2012 Apr 03, 2012

Copy link to clipboard

Copied

Thanks much. Appreciate your help

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
community guidelines
New Here ,
Apr 03, 2012 Apr 03, 2012

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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…

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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));

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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.

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