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

Illustrator - javascript to change all layers to same colour

New Here ,
Jun 26, 2024 Jun 26, 2024

Hello community,

I have searched everywhere for a script that changes all layers in Illustrator 2024 to the same colour.

The script I found is below but for some reason it doesn't work (no errors appear - just does nothing).

var doc = app.activeDocument;
var layers = doc.layers;
var LightBlueCol = new RGBColor();
LightBlueCol.red = 79;
LightBlueCol.green = 128;
LightBlueCol.blue = 255;
for(vari=0;i<layers.length;i++){
var aLay = layers;
aLay.color = LightBlueCol;
// layers[i].name = LightBlueCol + (layers.length - i).toString();
}
In the example below, I want to change all the Test layers to Light Blue (names of layers don't matter).
Test Illo Layers.png
Can anyone point me in the right direction please. I am not a coder and am new to this but for the life of me I can't see what the problem is.
Any help would be appreciated.
TOPICS
Scripting
214
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
Enthusiast ,
Jun 26, 2024 Jun 26, 2024

When updating the forum, the indexes of array elements disappeared in the old scripts. It was missing var aLay = layers[i].

 

var doc = app.activeDocument;
var layers = doc.layers;
var LightBlueCol = new RGBColor();
LightBlueCol.red = 79;
LightBlueCol.green = 128;
LightBlueCol.blue = 255;
for (var i = 0; i < layers.length; i++) {
  var aLay = layers[i];
  aLay.color = LightBlueCol;
  // aLay.name = LightBlueCol + (layers.length - i).toString();
}

 

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
New Here ,
Jun 26, 2024 Jun 26, 2024
LATEST

Perfect!

Thank you so much Sergey.

I tried changing a few lines myself but don't have enough knowledge of Javascript to make it work.

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