Skip to main content
Known Participant
June 24, 2009
Question

color abrev?

  • June 24, 2009
  • 1 reply
  • 1493 views

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.)

This topic has been closed for replies.

1 reply

Jongware
Community Expert
Community Expert
June 24, 2009

So .. something like

a = 200;

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

or

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

Known Participant
June 24, 2009

for each color in the library?

Jongware
Community Expert
Community Expert
June 24, 2009

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);

    -- well, something like that.