4 Replies Latest reply on Jul 6, 2012 5:06 AM by AI_learner

    How to find out that an art item has spot color using script?

    AI_learner Level 1

      Hi all,

       

      I have a number of art items on a document, some of them are filled with spot colors and some of them are with process color.
      Is there any method by which I can find out which color type(spot or process) is applied to the selected art item?

       

      Thanx in advance...

        • 1. Re: How to find out that an art item has spot color using script?
          CarlosCanto Adobe Community Professional & MVP
          var idoc = app.activeDocument;
          var ipath = idoc.pathItems[0];
          icolor = ipath.fillColor;
          alert(icolor.typename);
          
          • 2. Re: How to find out that an art item has spot color using script?
            AI_learner Level 1

            Thanx for the reply carlos....
            But I am not able to use "icolor.typename". There is nothing like "typename" showing in the properties.

            I am using it like this:

             

            var app:com.adobe.illustrator.Application = Illustrator.app;

                                                    var pathArt:PathItem;

                                                    var allPaths:PathItems           = doc.pathItems;

             

                                                    if ( app.documents.length > 0 && doc.pathItems.length > 0)

                                                    {

                                                                   var colorValue:com.adobe.illustrator.Color;

             

                                                                   //Fill color to the selected object.

                                                                   for (var i:int = 0; i < doc.pathItems.length ; ++i)

                                                                   {

                                                                                  pathArt = allPaths.index(i);

             

                                                                                  if(pathArt.selected)

                                                                                  {

                                                                                                 colorValue = pathArt.fillColor;

                                                                                                 trace(colorValue.typename);              //But colorValue doesn't show any property like "typename".

                        }

                                                                   }

              }


            Do am i missing some thing?

             

            Thanks...

            • 3. Re: How to find out that an art item has spot color using script?
              CarlosCanto Adobe Community Professional & MVP

              what's that? actionscript?

               

              did you try the sample I posted? try to duplicate the same sample in your version (as?), to see if it works.

               

              I think the problem is here

              var colorValue:com.adobe.illustrator.Color;

               

              can you run your code without declaring the colorValue first? comment it out to see if it works.

              • 4. Re: How to find out that an art item has spot color using script?
                AI_learner Level 1

                I tried your code and mine as well. It works fine if the document color mode is "RGB Color" but in case of "CMYK Color", it throws an exception

                 

                Error: In wrapReturnedHostObject(), attempted invalid wrap: com.adobe.illustrator::CMYKColor returned as com.adobe.illustrator::Color.

                 

                I don't know why.

                 

                But In rgb mode also, when i tried ur code and debug it, then line  "icolor.typename" returns the "RGBColor". But that's not what i want. I just want to know the value of 'color type' i.e. spot color or process color.

                Let me give you some more info may be it will help you to understand my problem..

                 

                I have a cmyk color mode document containing some art objects. These art objects are filled with some process color and some spot colors. When I select any art object, which is filled with some color, I want to get the 'color type' of the filled color and if it is possible then its value(r, g, b) and name too.

                 

                Is it possible to get all of these?

                Thanks..