I want a script that will change a swatch in my Illustrator document, where this particular swatch is named “strap”.
I looked over the Internet, and didn't find anything that worked, but I noticed people seem to string together .spot
and .color
in ways I don't understand. So for about twenty minutes I just randomly put together combinations of spot and color, and I found something that works. But I don't understand. Why is this “spot” necessary at all? How does it make sense to repeat “color” twice? Here is the code:
var doc = app.activeDocument;
var swatches = doc.swatches;
var my_color = doc.swatches.getByName("straps");
my_color.color.spot.color.red = 41;
my_color.color.spot.color.blue = 62;
my_color.color.spot.color.green = 78;