Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Creating a Script to Replace Supplied Swatches with Our Own...

New Here ,
Feb 22, 2011 Feb 22, 2011

We have a client that provides us art with their own swatches. We in turn have to load the corresponding swatch from our library for that client and merge. Would there be a way to script this?

They are not named the same but usually part of the name is the same. For instance, a supplied swatch is called 'White_S06_001A_white' and we replace it with 'WHITE_we_rgb'... or 'Red_SLD_A1MH_186' is replaced by '186_RED_we_rgb'

Wondering if this might be possible. Thanks.

TOPICS
Scripting
1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Advocate ,
Feb 22, 2011 Feb 22, 2011

I think it's possible (although it's beyond my scripting prowess) but

... usually part of the name is the same ...

usually is not going to work. Only if you have one of these:

  1. a list of all usual name differences (and all of them)
  2. or, an exact list of all of your clients' names and yours.

then a script can do it.

For (1), it needs the differences to discard and replace the bad name bits with the good stuff. For example, the "_we_" can be added right after the first underscore, and eh (thinking about your 2nd example ...), well, something like "if there is a number at the end place it at the start and replace the word before the first underscore with capitals and throw everything else away and add "_we_rgb" to the result" -- you get the idea. Is there any rule to this at all?

For (2), it just requires a simple "a -> b" translation list.

By the way: how do you know it's safe to change the name? Are the RGB values of your and their swatches identical?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 22, 2011 Feb 22, 2011

Is this just a re-naming of swatches exercise?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 22, 2011 Feb 22, 2011

Oh of course ...

Then all it needs is a list of this sort:

[ R, G, B ] "your Own Swatch Name"

.. and a script can test each of the supplied swatches' RGB values, setting your own name if the values match. The original name is then totally unimportant.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 22, 2011 Feb 22, 2011

Jong, sure if its just a rename exercise then you could loop the swatches for value matches or given a list of possibilities change the name but Im not seeing the purpose behind this? What affect on the contained art is this supposed to have?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2011 Feb 22, 2011

This is not just renaming the swatch. The values are different. The designers use colors they can see easily and view nicer on printouts (we believe).

Our values match what is wanted for final output.

When we manually do this, we find the corresponding swatch in our library, click on it to add it to the document swatch list, then merge it with the original swatch, changing the color of all objects using it.

Thanks for all the help so far.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 23, 2011 Feb 23, 2011

Illustrator does not offer a merge method to it's document swatches from script like Indesign does. Also bringing in new spots to a document is messy… Could you NOT rename the swatches and change their values?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 23, 2011 Feb 23, 2011

This sounds a lot like a customer we have. I remember trying to merge swatches in Illustrator, and found it was impossible in CS4. Is it possible in CS5?

A couple of questions?

1) Could a script be created to search for colors in the art by value, change the swatch to the "accepted" value and then change the swatch name so we would know it was changed.

2) Or, could you just use a portion or the name, like swatch which contains the word "white" or "White" or "WHITE" would get the "accepted" values applied? After the new values are applied, change the name so we know it was changed.

I've been wondering about this for years. I think I might even have some posts on this forum about it...

Thanks for any assistance.

Danny

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 24, 2011 Feb 24, 2011
LATEST

Finding matches in… and renaming swatches is simple to do you would use match(someRegExp) and replace(someString). As for looking for art coloured with certain values and changing them this too is possible but script does NOT have access to all thats available in the Illustrator GUI. So much would depend on the art in question. If I recall correctly changing the values of a colour in swatches with script breaks it's association with the document art… But that is something I would have to go back and check…

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines