7 Replies Latest reply on Feb 1, 2016 9:39 PM by Qwertyfly...

    Script to convert CMYK color to PMS color

    sdfasgdg

      Hello All,

       

      I have bunch of AI files that have thousands of objects with all different CMYK colors.

      What I need to do is converting them into Pantone solid coated (PMS) colors.

       

      I found a free script showing equivalent pantone color from the link blow.

      10 Free and Extremely Useful Illustrator Scripts - Vectips

       

      And trying to tweak to make the pantone color to be applied to the selected object.

      In below script, I added line 178 and 179 like below.

       

      activeDocument.selection[0].fillColor.typename = "SpotColor";
      activeDocument.selection[0].fillColor.color = matchlist[0];

       

      But it doesn't change the object's color.

      Could you let me know how to do this?

       

      I am not sure how to add script in this forum. Please download JS code from the link below.

      https://www.dropbox.com/sh/qdxo1pi482h6yyx/AACeeo-ko6-ZPlzwfzpjZZQaa?dl=0

       

      I am kind of new to scripting and wondering how to make this work.

      If anyone can give me some advice, it would be great.

       

      Thank you.

        • 1. Re: Script to convert CMYK color to PMS color
          Qwertyfly... Level 4

          I used to use this script a bit. it has not been updated in a long time so is missing many of the newer PMS colors, and I believe pantone has modified many of the CMYK breakdowns over the past few years.

          that said it should still give decent results if you don't need to be too accurate.

           

          if you look at the code, Wunds has included all the swatch names and all the breakdown for CMYK and RGB.

          it does not access a swatchbook in illustrator.

          this makes it much more then an added few lines here and there to get it to recolor automatically.

           

          in illustrator we don't have access to external swatch books from Javascript.

          a workaround to that is to save a document that has all the Pantone colors added to it's swatch pallet, then you can access them from there.

          this thread has some info on the topic. How do I script Illustrator to get a PANTONE swatch from a swatch library

           

          there is a built in function of the recolor Artwork Dialog that will convert colors to Pantone, but this is not scriptable with JS.

          it could be done using VB Script with a few SendKey statements, not ideal but could work...

          • 2. Re: Script to convert CMYK color to PMS color
            sdfasgdg Level 1

            Thanks Qwertyfly,

             

            It sounds like adding pantone color is more difficult than I thought,

            as an alternative, I am wondering if we can put the object in to the layer that has the name of pantone color?

             

            For this, I think,

            1) select 1 object and run above script to find out the pantone color name

            2) take the first pantone color name ( which I think "matchlist[0]" at line 162 )

            3) creating a layer with the name of the pantone color name (matchlist[0]) if it is not already exist.

            4) select all objects with the same fill color.

            5) move all selected object into the layer with the name of the pantone color.

             

            Could you let me know if this is feasible to think about? or could you help on coding for this?

             

            Thanks a lot.

            • 3. Re: Script to convert CMYK color to PMS color
              Qwertyfly... Level 4

              I can't see that being an issue.

              moving things to new layers based on their colour should not be hard.

              but it will mess with your stacking order!

               

              I would look at doing it right.

               

              create a new doc, delete all swatches, add all PMS swatches from desired colorbook

              this can be used to change the colours to the PMS swatch that it best matches

               

              the Wundes script works only on the first item in selection.

              you will need to make that a loop of all pathItems.

               

              it also only checks the fill, and not the stroke.

              a few more lines of code can fix that.

               

              you will also want to remove the "do you want to use pastels" dialog. and all other dialogs...

               

              you may also want to automate an increasing prec (precision) until it finds a match.

               

              depending on what you want this for it may also pay to export all this info to a text doc so you can find any colours that are a poor match etc.

               

               

              as you can see there is a few hours of messing around to tweak the script to do what you want.

              and I am happy to help out with some of it.

               

              give us some more info about how the final result is being used. I don't want to wast time on features that are not needed.

              • 4. Re: Script to convert CMYK color to PMS color
                Qwertyfly... Level 4

                here is a bit of a start.

                still does not do strokes.

                still can fail badly in some cases.

                 

                it's using the "PANTONE+ Color Bridge Coated" color book.

                this was loaded into the PMS.ai file

                save the .ai file in the same directory as the script file.

                 

                this should give you a good place to get started.

                qwertyfly.com/files/scripts/PMS.zip

                • 5. Re: Script to convert CMYK color to PMS color
                  sdfasgdg Level 1

                  Thanks a lot Qwerty.

                   

                  The concept of swatch book was new to me and a bit confused.

                  But I believe I get the idea and will take a look and try to make it work.

                  • 6. Re: Script to convert CMYK color to PMS color
                    Qwertyfly... Level 4

                    so is this kinda doing what you wanted?

                    if so, I'm glad I could help.

                    sing out if you get stuck finishing it off.

                    • 7. Re: Script to convert CMYK color to PMS color
                      Qwertyfly... Level 4

                      cool, like I said, let me know if I can help you out some more.

                       

                      with JS in illustrator we don't have access to swatch books.

                      but we do have access to the document swatches.

                      the PMS.ai file I made.

                      all I did was move all the colors from the "Pantone+ Color Bridge coated" in to the document swatches then save it.

                      then we can access the swatches from that document...

                       

                      I used the color bridge as this swatch book has colors like Process Cyan C, unlike the newer Solid Coated V2 book. (I think they even have a newer one now)

                       

                      just as a note.

                      if you are looking for what I have changed.

                      all changes I made have comments to show what I did.

                      ie.

                      // QF - now we open the document with all the PMS swatches in it.