1 Reply Latest reply on Sep 6, 2012 10:53 PM by CarlosCanto

    Color Names

    Joce Nunes

      Hello everyone,

       

      I would like know, if this is possible,  for example, I Create a square with size 10mm X 10mm and next to square a script that writing the name of color that i used that object.

       

      How bellow in the red area:

       

       

      Captura de Tela 2012-09-06 às 08.59.01.png

       

       

      Good, thanks

       

      Joce

        • 1. Re: Color Names
          CarlosCanto Adobe Community Professional & MVP

          the following script works only if your swatches are "Spots"

          labelColorUsed.PNG

           

          select your little squares before running

           

          var fontSize = 20;
          var spacing = 6;
          
          
          var idoc = app.activeDocument;
          var sel = idoc.selection;
          
          
          for (j=0; j<sel.length; j++) {
              var ipath = sel[j];
              var itext = idoc.textFrames.add();
                    try {
                              var icolor = ipath.fillColor;
                              itext.contents = icolor.spot.name;
                    }
                    catch (e){
                              itext.contents = 'Convert to Spot';
                    }
          
          
                    itext.textRange.characterAttributes.size = fontSize;
                    itext.left = ipath.left + ipath.width + spacing;
                    itext.top = ipath.top - ipath.height/2+ itext.height/2;
          }