Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Swatch Legend Generator Script (Spots only) help

New Here ,
Jan 10, 2019 Jan 10, 2019

Hi I have this script for generating a legend of the swatches however:

1) I only want to show the SPOTS and not any cmyk / rgb / colours (as described in the image at the bottom)
2) I want the height of the text box to go three lines deep not just two (as indicated by the image at the bottom)

How would you modify the following script to achieve this? – I'd be very grateful for any tips...

---

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 ); 

Screen Shot 2019-01-10 at 16.38.37.png

TOPICS
Scripting
468
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Valorous Hero ,
Jan 10, 2019 Jan 10, 2019
LATEST

I think first tip is to use 'var' to declare all your variables that you don't want to appear in subsequent script runs and cause bugs due to pollution of global scope.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines