6 Replies Latest reply on Jun 29, 2009 7:56 AM by Seth McGraw

    color abrev?

    Seth McGraw Level 1

      We have a script (javascript for cs3 & 4) that allows a user to type in colors (among other things) and puts those colors in a new document's swatches. Those colors are chosen from a custom library of spot colors set up by our corporate office. The color names do in fact coincide with their numerical counterparts

      :example: myScarlet200 = PANTONE 200 C. currently the user types in PANTONE 200 C and it has to be exact or the script will fail. We would like the user to simply be able to type in "200" and have the correct color assigned. I'm hoping someone has already taken insane time to do the solid coated library in such a way (so we could pillage the code), or be able to advise on the most expedient way to associate colors with their pantone equivalent numbers for the purpose of dialog entry in cs3 or cs4.


      Thanks in advance


      (The script creates a custom template for art design and the color entries eliminate the need to load colors manually. The script saves all of the art departments time division wide, however a main complaint is that the script fails when a typo is made entering colors. We are trying to fix that part of the script.)

        • 1. Re: color abrev?
          [Jongware] Most Valuable Participant

          So .. something like


          a = 200;

          app.activeDocument.importAdobeSwatchbookProcessColor ("Pantone "+a+" C");


          app.activeDocument.importAdobeSwatchbookSpotColor ("Pantone "+a+" C");

          • 2. Re: color abrev?
            Seth McGraw Level 1

            for each color in the library?

            • 3. Re: color abrev?
              [Jongware] Most Valuable Participant

              Errr... No? Only for those that are needed?


              As you said, the end user has to type in the entire string "Pantone 200 C". If you let them enter just the number ("200" in this case), you can stick "Pantone " in front and " C" at the end, and use that to copy the color string out of the library into the currenty active swatches.


              If you need something else, like, the entire Pantone library added to the swatches: personally I'd script even that, but you could add them one by one by hand (...*) but then you can save the swatches into a swatch book file, and that can be loaded into any other document when needed. Save and Load are options in the Swatch panel menu.


              [*] Oh okay, here is a how-to for that. Get a list from the Pantone color names you need (I know at least one website that provides it, against Pantone(R)'s rules). With a good plain text editor (not the ESTK) you can easily convert it into array form:


              allColorsInTheWorld = new Array (

              "Pantone 100 C",

              "Pantone 101 C",

              "Pantone 102 C",

              .. several thousand lines omitted for brevity ..

              "Pantone 9999 C" );


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

                app.activeDocument.importAdobeSwatchbookProcessColor (allColorsInTheWorld[i]);


              -- well, something like that.

              • 4. Re: color abrev?
                Seth McGraw Level 1

                I think my question has been misunderstood. I'll use this example:


                We're doing a book cover for a customer and that customer has decided on a particular vector illustration and logo on the front (cover style template).

                They can choose any colors to represent the 3 colors allowed for this package.

                on to the script...


                The dialog will ask the artist doing the cover a series of questions that builds the template based on those entries (all that is already done).

                One of those categories is colors. The customer may choose between 0 and 4 colors in this option set.



                The script loads document colors from an .indd document in a static location that contains all of the colors and we will remove unused colors at the     end via script leaving behind only the ones from the dialog entry in the swatches panel (that is because we don't know how to pull entries from a    library that isn't available to the active or new document)

                Currently the dialog entry requires the full name (PANTONE 200 C) case sensitive and spelled exactly as the library.



                I would like to be able to just enter "200" in the dialog instead of the full color name in the library.


                my question: How can I associate 200 with PANTONE 200 C (along with every other color in the solid coated library) using 200 as the common thread?

                Do I have to say: "200 = PANTONE 200 C" for every color so when I call 200 it gives me PANTONE 200 C?


                You may have understood the question and I just don't get it (the answer). please don't flame me for my ignorance.





                ps: notice in the color picker in the InDesign you can just type 200. In a nutshell that's what I want to accomplish through script in a dialog.

                • 5. Re: color abrev?
                  [Jongware] Most Valuable Participant

                  (While waiting for the image to pop up:) The colors that are entered into the dialog are added to the active document's swatches, correct? The user types in "Pantone 200 C" (amongst other things) into the dialog, presses "OK" and these swatches are added?

                  Can you show part of this script that adds the entered colors to the document? It should look something like


                  app.activeDocument.importAdobeSwatchbookSpotColor (dialogValueHere);


                  where dialogValueHere is a variable containing what the user entered -- a full color name. It's at this point that you can stick "Pantone " in front of the entered value and " C" at the end:


                  app.activeDocument.importAdobeSwatchbookSpotColor ("Pantone "+dialogValueHere+" C");


                  will work if the value entered is plain "200".


                  It is possible that the way of adding the color is done differently, because


                  that is because we don't know how to pull entries from a    library that isn't available to the active or new document


                  -- using "importAdobeSwatchbookSpotColor" or "importAdobeSwatchbookProcessColor" is the recommended way. Perhaps the script is quite old.

                  • 6. Re: color abrev?
                    Seth McGraw Level 1

                    Actually we add in all of the colors in the library, apply the colors to objects, and then "delete unused colors" from the swatches.

                    I will try it the way that you have written and get back to you. Thanks