7 Replies Latest reply on Aug 27, 2013 9:20 AM by W_J_T

    find same pantone color

    surendarappu Level 1

      Hi

      Any one plz help me to find same pantone colors in selected object

       

      here is my code

       

      doc = app.activeDocument;

      if (app.documents.length>0)

      doc.selectObjectsOnActiveArtboard();

      selectList = doc.selection;

      cou = selectList.length;

      if(cou>0)

      {

          for(i=0;i<cou;i++)

          {

      if(selectList[i].fillColor=="[SpotColor]")

      txt=selectList[i].fillColor.spot.name;

      }

      }

       

      i want to find the pantone name present in txt variable with other selected list

       

      plz help me

       

       

      Thank you

        • 1. Re: find same pantone color
          W_J_T Level 4

          Based upon the code you posted and the description you provided, I am unclear what it is you're hoping to accomplish?

          Can you try to explain in more detail what you're having trouble with?

          • 2. Re: find same pantone color
            surendarappu Level 1

            hi W_J_T

             

            ok i will explain you

             

            in variable txt spot color name will be their right for example PANTONE 314u

            now i want to check the same pantone color appear again in selected iteam

             

            Thank you

            • 3. Re: find same pantone color
              W_J_T Level 4

              So you mean something like this?

               

              // [...]
              var pantoneSpotName = "PANTONE 485 C";
              // [...]
              if (selectList[i].fillColor.spot.name == pantoneSpotName) {
              // [...]
              }
              // [...]
              

               

              I didn't try it with your provided code, but reworked it a little and it works for me, if that is in fact what you mean. Does that help?

               

              Also the Illustrator IDE has this type of selection built in as an actual feature (in case you were unaware of it).

              Select (Menu) -> Same -> Fill Color

              • 4. Re: find same pantone color
                surendarappu Level 1

                Above provided code is similar to my expectation , if we know that PANTONE 485 C or any other name...

                insead of PANTONE 485 C, i want to store the color of first object  in doc.selectObjectsOnActiveArtboard();

                then i wnat to check that same color appear again

                • 5. Re: find same pantone color
                  W_J_T Level 4

                  surendarappu wrote:

                   

                  i want to store the color of first object  in doc.selectObjectsOnActiveArtboard(); then i wnat to check that same color appear again

                   

                  Well, this is now in fact different than what you posted you wanted above in Post #2. But if that is what you want now then by using selectObjectsOnActiveArtboard you don't have much control over what color will be picked, meaning it will pick the front most item, which may or may not be the color/item your hoping to target. Sounds like from your description now you would want to target the active "doc.selection[0];" find it's color and utilize that for your comparison and execution. Which leads us back to: Select (Menu) -> Same -> Fill Color

                  • 6. Re: find same pantone color
                    surendarappu Level 1

                    Hi W_J_T

                     

                    I'm asking the same question from my first post.

                     

                    i use doc.selection as you said still i could not find

                     

                    here is my code

                    if (app.documents.length>0)
                    doc.selectObjectsOnActiveArtboard();
                    selectList = doc.selection;

                    co=0;
                    if(selectList.length>0)
                    {
                         for(i=0;i<selectList.length;i++)
                         {
                         if(selectList[i].fillColor=="[SpotColor]")
                         txt=selectList[i].fillColor.spot.name;

                    if(txt==selectList[i].fillColor.spot.name)//check for same color

                    co+=1;//if color is same 1 will be added to co;

                    if(co>=2)//same color appears again

                    alert(txt);

                    co=0;//making co to 0

                    }

                    }
                    can you please modify my code to find same color appears again

                     

                    Thank you

                    • 7. Re: find same pantone color
                      W_J_T Level 4

                      I already mentioned in post #5 you need to target something and it's color to reference and check against, please reread it, you're not doing that. Plus every time you post a new explanation or code I get more confused as to what you're truly hoping to accomplish.