I’m very new to illustrator and I have not done scripting before, I have like a hundred illustrator files that I need to change the background color lets say background color is layer 5 for every file, can scripting make it like repeat changing the background color for all my files, i would really appreciate some help with how to start writing a script.
var doc = app.activeDocument; var layers = doc.layers; var colortest = new RGBColor(); colortest.red = 251; colortest.green = 237; colortest.blue = 31; layers.color = colortest;
i havent done any scripting before, and ive just been researching for a while and its really confusing me. i tried the script above based on my researches but its wrong.instead of changing the blue color of the layer it changes that yellow color thing
The issue is that you’re targeting the wrong scripting object to command.
The layer.color is simply the layer’s color-marker inside the layers panel.
What you want to do is actually change the artwork inside the actual layer. Check out the edited script here- it uses the collection of pathItems inside a layer to target the first path. This will only work if your blue shape is a rectangle inside the layer – and is not part of any group but is a top-level piece. (Open up your individual layers inside the layers panel to observe the artwork grouping structure) It will also not work if your blue shape is a raster image, etc.
var doc = app.activeDocument;
var layers = doc.layers;
var colortest = new RGBColor();
colortest.red = 251;
colortest.green = 237;
colortest.blue = 31;
layers.pathItems.fillColor = colortest;