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:

  1. Marizmendi8:21 PM

    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

    ReplyDelete
  2. 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.

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

    ReplyDelete
  4. 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?

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

    ReplyDelete
  6. wonderful, thanks :)

    ReplyDelete
  7. Jim de Bruin9:07 AM

    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

    ReplyDelete
  8. Anonymous9:50 AM

    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?

    ReplyDelete
  9. 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.

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

    ReplyDelete
  11. 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.

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

    ReplyDelete
  13. Anonymous1:54 PM

    How do I do the following:

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

    Thanks!

    ReplyDelete
  14. Anonymous8:45 AM

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

    Thanks!

    ReplyDelete