Adode Illustrator Ledgend Script not working.
Hello Guys,
I am trying to run the following Script to generate swatch ledgend. I am getting the errod you can see on the screen shot, Can somebody assist me. I tried another simular script but also got the same error.
SCRIPT:
doc = activeDocument,
swatches = doc.swatches,
cols = 4, // number of columns in group
displayAs = "SPOTColor", //or "CMYKColor"
printColors = ["SPOT"], // RGB, CMYK, LAB and/or GrayScale
textSize = 6, // output text size value in points
rectRef=null,
textRectRef=null,
textRef=null,
swatchColor=null,
x=null,
y=null,
w=16; // width of ellipse
h=16, // height of ellipse
h_pad = 45, //distance between swatches horizontally
v_pad = 10, // distance between swatches vertically
t_h_pad = 55, //width of text box
t_v_pad = 2, //vertical position of text box - more means lower
activeDocument.layers[0].locked= false;
var newGroup = doc.groupItems.add();
newGroup.name = "NewGroup";
newGroup.move( doc, ElementPlacement.PLACEATBEGINNING );
for(var c=2,len=swatches.length;c<len;c++)
{
var swatchGroup = doc.groupItems.add();
swatchGroup.name = swatches.name;
x= (w+h_pad)*((c-2)% cols);
y=(h+v_pad)*(Math.round(((c)+.03)/cols))*-1 ;
rectRef = doc.pathItems.ellipse(y,x, w,h); //circle or rectangle
swatchColor = swatches.color;
rectRef.fillColor = swatchColor;
rectRef.stroked=false;
textRectRef = doc.pathItems.rectangle(y- t_v_pad,x+ t_h_pad, w-(0.95*t_h_pad),h-(1*t_v_pad)); // padding between ellipse and text box
textRef = doc.textFrames.areaText(textRectRef);
textRef.contents = swatches.name;
textRef.textRange.size = textSize;
rectRef.move( swatchGroup, ElementPlacement.PLACEATBEGINNING );
textRef.move( swatchGroup, ElementPlacement.PLACEATBEGINNING );
swatchGroup.move( newGroup, ElementPlacement.PLACEATEND );
}


