5 Replies Latest reply on Jan 2, 2013 1:30 AM by indegn5

    find colorValue and alert

    rajnikids Level 1

      hi forum,

       

      i want to find the colorValue and give an alert. my color value is c:100, m50, & Y0,K0;

       

      the below script alerts even if the pageItems has different color; but when the page doesnt contains any pageItems.. the alert message is not found;

       

      basically i need the alert to be made when the page items has only the above said colorvalue;

       

      var mydoc = app.activeDocument;

      var myPItems = mydoc.pageItems.everyItem().getElements();

      for (i=0; i<myPItems.length; i++) {

      myPItem = myPItems[i];

           if (myPItems.colorValue == "100,50,0,0") {

              }

      alert ("document has old color value")

      }

       

      help on this,,

       

      thanks

      rkids.

        • 1. Re: find colorValue and alert
          Jump_Over Level 5

          Hi,

           

          1.      .colorValue is a property of Color (Swatch),

          2.     its value is an array,

          3.     to compare these values use .join() method to convert an array to a string,

          so use it like this:

           

          var mydoc = app.activeDocument;

          var myPItems = mydoc.pageItems.everyItem().getElements();

          for (i=0; i<myPItems.length; i++)

               {

               myPItem = myPItems[i];

               if (myPItem.fillColor.colorValue.join() == "100,50,0,0")

                    alert ("document has old color value");

               }

           

          rgds

          • 2. Re: find colorValue and alert
            rajnikids Level 1

            hi jump_over,

             

            thanks for the reply..

             

            it tried for with strokeColor of the same value and with fill colour at a same time... but nothing happens, only when the fillColor or strokeColor is defined seperately, it works...

             

            thats Y, i tried for only myPitem.colourValue..... where it should throw alert for, all the fill/stroke/text colour which has 100,50,0,0..

            any help on this...

             

            tbanks

            rkids.

            • 3. Re: find colorValue and alert
              indegn5

              hi forum,

               

              in rajnikids first mail... the script is particular to find fillcolor.colorValue... but i have a question....

               

              if the document has the colorValue 100,50,0,0 for.....    it can be a Textcolor or box Fillcolor or a stroke color.....

               

              how? can we simply declare just the colorValue and get the alert...

               

              alert ("the doc has 100,50,0,0")..

               

              thanks

              bobby...

              • 4. Re: find colorValue and alert
                Jump_Over Level 5

                Hi,

                 

                To do it simply delete unused colors in document and the list of Colors in panel "Swatches" could be read alike this alert.

                 

                rgds

                • 5. Re: find colorValue and alert
                  indegn5 Level 1

                  thanks jump_over,

                   

                  I just added to the rajnikids request.

                   

                  I m trying to find the, text/stroke/fills with the specific colour value and then alert. my request is not about deleting unused swatches...

                   

                  many apologise, if my posting has wrong request or my posting is unclear. sorry jump_over...

                   

                  thanks

                  bobby.