Changing the color of a duplicate
Working on a script to create multiple squares of different colors. The idea is the user CMD-selects the swatches used in the art file, runs the script and a prompt asks them to choose a size. Then based on how many swatches are selected, that many squares are created in the colors selected. In other words if they select red and blue swatches, the script should return one red square and one blue square in the selected size. I'm able to create the squares based on swatch selections but not able to apply more than one color. Any ideas? I want to keep the code as clean as possible. Thanks!
var doc = app.activeDocument;
var ppi = 72;
var horOffset = 0;
if(app.documents.length > 0){
selSwatches = doc.swatches.getSelected();
if(selSwatches.length != 0){
swatchIndex = selSwatches.length-1;
swatchIndex2 = selSwatches.length-2;
swatchIndex3 = selSwatches.length-3;
swatchIndex4 = selSwatches.length-4;
swatchIndex5 = selSwatches.length-5;
for (var i=0; i<selSwatches.length; i++)
{ var blockCount = i+1}
}}
var printMarks = doc.layers.add();
printMarks.name = "Standard Print Marks";
var Square = .25;
var Square2 = .375;
var Square3 = .5;
var Square4 = .75;
mySquareSelect = Square4;
mySquare = ppi*mySquareSelect;
var horzOffset = mySquare*1.5;
theSquare = printMarks.pathItems.rectangle(0,0,mySquare,mySquare);
theSquare.filled = true;
theSquare.stroked = false;
//~ theSquare.fillColor = selSwatches[swatchIndex].color;
theSquare.postion = [0,0];
for (var j=0; j<blockCount; j++)
{ myDuplicate = theSquare.duplicate();
myDuplicate.position = [theSquare.position[0] + horzOffset * j, 0];
myDuplicate.filColor = selSwatches-1;}
blockCount;
