I recently created a script that reads the layer names of an Illustrator file, and uses the name to identify a swatch to use to pattern all elements on that specified layer. The script works well, and is a real time saver for our mapping staff, but it requires duplicate swatches to exist, where the only difference is their colour.
To improve the script I want to duplicate a swatch and modify its' colour before applying it to a specific layer. I think the only way this can be done is via the "placedItems" command. So the code I'm trying to write looks likke this:
for(var s=0; s<slib.length; s++){ // search swatch library
var pat=slib[s].name; // get swatch name
if(pat == patTile){ // does it match specified pattern
//match found...place on Temp_Pattern layer
var placedTile=doc.placedItems.add(); // my attempt to place swatch on a specied layer/location
placedTile.file=doc.slib[s];
placedTile.layer=doc.layers[0];
placedTile.left=0;
placedTile.top=0;
}
}
However I'm struggling to find the correct syntax to make this work. Can someone help me?