2 Replies Latest reply on Jan 3, 2017 12:45 PM by cbishop01

    Creating Color swatches?

    cbishop01 Level 2

      I've came across this script Scripting Help! Batch color swap between libraries.  My question about this is.  How would i edit this to make multiple columns per page as opposed to listing them in one column?  THis works great For if we make a color book.  however we would also like to print a Roll of swatches.  IF this is insanely complex i'll just use this one.

       

      Here's the script thats working so far..  This was made by ""

      // Script by Trevor to make CMYK color Swabs http://forums.adobe.com/message/4890389#4890389  
      var il = app.scriptPreferences.userInteractionLevel;  
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;  
      app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.ENTIRE_SCRIPT, "Make CMYK Swabs");  
      app.scriptPreferences.userInteractionLevel = il;  
      
      function main()  
      {  
          var swatchDoc, doc, swatchColors, l, newSwatch, newSwatchName, cv, ps, m, mtb, tb, ms, tf, ptf;  
          swatchDoc = app.activeDocument;  
          setupDoc();  
          app.activeDocument = doc;  
          swatchColors = swatchDoc.swatches.everyItem().getElements();  
          l = swatchColors.length;  
          while (l--)  
              {  
              if (swatchColors[l].name != "None" && swatchColors[l].name != "Registration" && swatchColors[l].name != "Paper")  
                  {  
                  newSwatch = doc.colors.add ({model: swatchColors[l].model, space: swatchColors[l].space, colorValue: swatchColors[l].colorValue});  
                  newSwatch.space = ColorSpace.CMYK;  
                  cv = newSwatch.colorValue;  
                  newSwatchName = "C="+cv[0]+ " M="+cv[1]+ " Y="+cv[2]+ " K="+cv[3];  
                  newSwatch.name = (doc.swatches.itemByName(newSwatchName).isValid) ? newSwatch.name : newSwatchName;  
                  ps.insertionPoints[0].contents = "\r"+swatchColors[l].name+"\r"+newSwatch.name+"\r"  
                  ps.insertionPoints[0].rectangles.add({geometricBounds:[0, 0, "15mm", "45mm"], fillColor: newSwatch.name /*  appliedObjectStyle: myStyle */});  
                  };  
              }  
          ps.overflows ? addPages(tf): 0;  
          function setupDoc()  
              {  
                  doc = app.documents.add({documentPreferences:{facingPages:0, pageOrientation: PageOrientation.PORTRAIT}});  
                  m = doc.pages[0].marginPreferences;  
                  mtb = doc.pages[0].bounds;  
                  tb = doc.pages[0].bounds;  
                  mtb[0]=mtb[2]-m.bottom;  
                  ms = doc.masterSpreads[0].textFrames.add ({geometricBounds:mtb, textFramePreferences:{verticalJustification:VerticalJustification.CENTER_ALIGN}});  
                  ms.parentStory.properties = ({digitsType: DigitsTypeOptions.ARABIC_DIGITS, hyphenation: 0, justification: Justification.CENTER_ALIGN, paragraphDirection: ParagraphDirectionOptions.LEFT_TO_RIGHT_DIRECTION, contents: SpecialCharacters.AUTO_PAGE_NUMBER});  
                  tb[0] += m.top; tb[1]+=m.left; tb[2]-=m.bottom; tb[3]-=m.right;  
                  tf = doc.pages[0].textFrames.add({geometricBounds:tb})  
                  ps= tf.parentStory;  
                  ps.properties = {digitsType: DigitsTypeOptions.ARABIC_DIGITS, hyphenation: 0, justification: Justification.LEFT_ALIGN, paragraphDirection: ParagraphDirectionOptions.LEFT_TO_RIGHT_DIRECTION, rightIndent: 2};  
              }  
              function addPages(ptf)  
              {  
                  np = doc.pages.add();  
                  ptf = np.textFrames.add({geometricBounds:tb, previousTextFrame: ptf});  
                  if (ps.overflows) addPages(ptf);  
              }  
      }  
      
      
      
      

       

      Thanks

      Chris