So .. something like
a = 200;
app.activeDocument.importAdobeSwatchbookProcessColor ("Pantone "+a+" C");
app.activeDocument.importAdobeSwatchbookSpotColor ("Pantone "+a+" C");
for each color in the library?
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++)
-- well, something like that.
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.
image1.jpg 32.7 K
(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
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.
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