Skip to main content
Disposition_Dev
Legend
April 30, 2019
Question

Looking for a Merge Swatches Workaround

  • April 30, 2019
  • 3 replies
  • 2503 views

I have a scenario in which i need to replace some placeholder colors with production colors (that will be determined at runtime from some data). The placeholder colors exist inside a textFrame with multiple layers of appearance and often time there are gradients involved, so I cannot utilize "Select Same Fill/Stroke".

For many instances, I can simply change the name and color value of the placeholder swatch to match the desired production swatch. However this does not work if i need to change two placeholder swatches to the same production swatch (because i receive an error when trying to use a swatch name that already exists..)

Anyone have any ideas in this regard? All of the colors i'm working with are spot colors.

This topic has been closed for replies.

3 replies

Inspiring
May 16, 2019

Please update on this post whenever we get a workaround or anything from Adobe side. I am also waiting for this feature. Why they don't expose some command to JS to merge swatches.

Disposition_Dev
Legend
May 17, 2019

I'll definitely update if adobe responds.. but that seems less and less likely by the day. Evidently this functionality was last available in CS5.. That means that Adobe has not yet responded to this issue in over 7 years...

Participant
May 17, 2019

So I've been looking at the Adobe sdk, I'm thinking of creating a simple plug in for illustrator to help with scripting, send the plug in simple commands to do stuff that scripting, actions or menu commands can't do.

For example "mergeSwatch:5,6"

You can also get the version number or a list of supported commands and get the user to download the latest version if it's out of date.

Something we can all use. We can make a public guthub project, and call it scriptSupport etc. We can add commands to expand script support or just make stuff faster.

There are demo plugins in the sdk, Does anyone have experience with this stuff?

My only issue is time at the moment, so many projects and stuff so to it would be hard to get started on this.

Glenn Wilton

Inspiring
May 10, 2019

I was thinking about this.....

You can not change mesh Gradient or Multiple Stoke colors with the script, but you can via a "Select same Fill Color" command where it selects the items (even in clipping paths etc) and you can click on a swatch to change the color. but from the script you can not select the swatches. You need the user to do the clicking.

The best I could come up with is a "User Guided Process" where the script checks an prompts the user to do the necessary actions....

You could do this.... you need a CEP panel or a non modal script UI panel...

1) Create the new swatches you need

2) Create a rectangle on the page or out of sight (very top left of the canvas) and fill and stroke it with the OLD swatch color (Perhaps also tag it)

3) Use excMenuCommand to select Same Fills

4) Check the selection length .. if its 1 then there are no other items on the page the same fill, If its >1 then prompt the user to change the color manually in the swatches "Please select PMS 380 as the FILL then press OK"

5) Check the temp rectangle is now the right color, if not get the user to repeat

6) as a double check reset the temp rectangle back to the OLD swatch and repeat the Select Same Fill command to ensure its length is 1.

7) Repeat for Strokes

8) Remove the temp rectangles. (Find by tags to get all of them?)

It would be a semi-auto method of changing the colors, less prone to human error. And easy to confirm its been completed correctly by checking the selection length is 1 for every color.

You could also temporally change the swatch name , i.e Instead of changing to "Pantone 380 C" change it to ">>SELECT ME AS FILL<<" so its easier for the user to select the right swatch, then change the name back?

OR is is possible to create a Custom Action to select the correct swatch??

---------------------------------------------------------------------------

EDIT: Actually YES, you can create and load a custom action to select a specific swatch by color, load the action, run it then remove it.

[Illustrator]Create, load and execute action all by JS only · GitHub

This command in the action looks easy enough to select the swatch by Name

/event-2 {

  /useRulersIn1stQuadrant 0

  /internalName (ai_plugin_swatches)

  /localizedName [ 8

   5377617463686573 <<< This is a Hex Encoded String = 'Swatches'

  ]

  /isOpen 1

  /isOn 1

  /hasDialog 0

  /parameterCount 1

  /parameter-1 {

   /key 1937204072

   /showInPalette -1

   /type (ustring)

   /value [ 20

    433d3135204d3d31303020593d3930204b3d3130  <<< This is a Hex Encoded String 'C=15 M=100 Y=90 K=10' which is the swatch name

   ]

  }

}

Disposition_Dev
Legend
May 1, 2019

I actually found a way to select two swatches from a script!!!! WOOOOH!!! my problems are solved!!!

NOT!

even when you have two or more swatches selected in your swatches panel, you still cannot merge the two swatches from an action... WHY ADOBE?! WHY DO YOU TORTURE US THIS WAY?! PLEASE FIX THESE DAMN PROBLEMS!!! IT'S BEEN ALMOST A DECADE AND YOU'VE NEVER RESPONDED TO A SINGLE COMPLAINT AMONG THIS ENTIRE COMMUNITY!

Inspiring
May 4, 2019

The only way I found to do this is to recursively loop over all the selected pathItems and check the Fill and Stroke properties, manually replacing A with B.

You can then remove the swatch

Disposition_Dev
Legend
May 4, 2019

Yea unfortunately that's the only option I can see... I think I'll throw that function behind my default of changing swatch names and values. If I can get away with just changing switches, that's vastly superior to the recursive loop. Some of the artwork I'm processing is quite complex and contains 10s of thousands of pathItems or more. Plus they were all built by many different people at different times, and I've already come across some wonky stuff like compoundPathItems that have no pathItems inside as far as the script is concerned because the compoundPathItem was created out of only groupItems somehow...

It's all doable, but pretty complex and certainly not very efficient.

And after I just typed all of that I realized I still can't do that because much of the artwork is live text with complex appearances with several different fills and strokes and effects. I don't believe I can access those from the script.