Illustrator CS3: Sort by Hue, Saturation or Brightness script

sortBy.jpg

Sometimes when I’m working with a lot of colors in my Swatches Panel in Illustrator, I want to sort them by Hue, Saturation or Brightness. To do so, I use a jsx script I made, SortByHue-Sat-Bri, which you can download here and use at your own discretion. Please note that it currently only supports the conversion of RGBColors. At some point in the future I will expand it to support CMYK. ;)

How to
Download and unzip the script. I typically place the .jsx scripts in the Scripting folder located in the Adobe Illustrator application folder. By doing so, the script will be available on the next launch of Illustrator under File: Scripts.

After you have moved the SortByHue-Sat-Bri.jsx into the Scripting folder, restart AI if it is currently open. Open a document and select File: Scripts: SortByHue-Sat-Bri. A prompt will ask you how you want to sort the colors in the Swatches Panel. Enter H for Hue, S for Saturation or B for Brightness. The Swatches should be rearranged and renamed with the HSB values. If you would like to revert to the previous order, simply undo this step (Edit: Undo).

Please note that I have only tested this on AI CS3. If you run into any issues, feel free to drop me a line. The RGBtoHSB and HSBtoRGB conversion methods were modified for AI, but are based on the original work by Veronique.

woohoo!
drew

Brought to you by…
If you dislike using Adobe Acrobat files, how about converting PDF to text or convert PDF to Word to make document management a little easier.  You can buy software including this PDF to DOC converter to take care of all your PDF conversion needs.

Stumble it!

6 Responses to “Illustrator CS3: Sort by Hue, Saturation or Brightness script”

  1. madcream10 Says:

    I’d like to note that Fireworks 2+ had sort by popularity and luminance.
    The sort by luminance is excellent for finding artfully good color contrasts to use as text and text backgrounds.

  2. dr. woohoo Says:

    thanks for the heads up. it’s been a long time since i used it, but debabelizer use to have some excellent ways to sort palettes, too. i have to say though, i’m very happy about AI CS3’s Color Guide Panel. the AI team did a wonderful job with that feature. the kuler SWF panel integration is pretty seamless as well and i’m looking forward to further integration of Flash swfs and the adobe host apps.

  3. roth.co. Says:

    Looks like a great script - however I keep getting an error when i’m running your script:

    Error 1224: Numeric value expected
    Line: 61
    -> newRGBSwatch.color=newColor;

  4. dr. woohoo Says:

    great catch! i obviously live in the world of rgb… but i’m slowly migrating towards print. this error is based on the fact that the palettes i am sorting, from In The Mod and/or kuler, are RGB. in the future, i will add sorting to a swatches palette that was originally cmyk…

  5. Martin Says:

    Great work!

    This is exactly what i need, but of course CMYK and CS4! Can’t get it to work now, I get the “ReferenceError: i is undefined” and then the “Error 2: rgbType is undefined. Line: 61 - > alert(rgbType);”

    Any news on an update?

  6. dr. woohoo Says:

    thanks martin. it should be technically possible to pull this off now, however, it’s just not a high priority for me rightdue to the fact that most of the new large format printers that i’m working with don’t mind rgb. you might want to post on the illustrator forum at adobe… i would be really surprised if someone has not already done this.

    good luck.

    d.

Leave a Reply