Wednesday, November 23, 2011

Generate Color Legend from Swatches

Here's a simple script that will generate color rectangles in a document for every color in the main swatch palette.


Suppose that you want to create a visual legend of some colors.  This script will make a map of ALL the swatches in the documents swatch palette.  (If you want to skip the "none" and "registration" values, just edit the script so the "for" loop start at 2 instead of 0.)

Just run this script, and a legend of named swatch rectangles with (by default) their CMYK values will appear in a nicely grouped object on the top of your document.

Sound off in the comments if you find this one useful.

cheers,
-J

14 comments:

Marizmendi said...

Hey, this is something I need every day in my job, I will give it a try and thanks to you for sharing this..

Mario
From Colombia

Ana Pereira said...

It is very usefull, I will use it a lot and recomend.
If I could I would add an improvment: The text label over black swatch or very dark colors should be in non black color.

John said...

Great idea Ana!
Labels now render white over dark swatches.
cheers,
-J

Tom said...

This is really useful. I've been doing the same thing for ages by hand. You've saved me countless hours!

If I may suggest, how about a little spot in a white triangle, like in Illy's color palette, for spot color swatches?

John said...

Good Idea Tom. I'll see about incorporating that into the next version...

IVAN said...

wonderful, thanks :)

Jim de Bruin said...

Great script.
One suggestion:
Instead of using 'Math.floor', it's better to use 'Math.round'.
In that case they correspond with the official Pantone Process CMYK values for:
• Color Bridge Coated / Uncoated
• CMYK Coated / Uncoated
• GoeBridge Coated

Anonymous said...

What a wonderful script! Thanks so much for sharing!

What line of code would you edit to customize the location where the color swatches are placed in the artboard?

John said...

There is no "offset" variable, it just renders from the top left of the current art board.
The lines to check out are 47 and 48. If you add in a baseline value it should render from there.

Em said...

THANK YOU! I just found your script and it saved me oodles of time on a silkscreen print file. Much appreciated!

walter said...

OK, maybe I'm just blind...

I DLed this collection of scripts, but I can not locate "Generate Color Legend from Swatches" script.

Also, what would really be cool is a script that created a swatch panel AND a swatch panel collection (like this script) from all colors on an artboard.

John said...

Hey Unknown, It's called renderSwatchLegend.jsx.
Neat idea. Let me play with it.

Anonymous said...

How do I do the following:

- remove all texts except Pantone number.
- move text under the box.

Thanks!

Anonymous said...

Been looking for this for a long time! Thank you!
renderSwatchLegend.jsx still worked great on Illustrator CC 2020

Thanks!