Skip to main content
Participant
January 28, 2016
Answered

Script to convert CMYK color to PMS color

  • January 28, 2016
  • 1 reply
  • 7832 views

Hello All,

I have bunch of AI files that have thousands of objects with all different CMYK colors.

What I need to do is converting them into Pantone solid coated (PMS) colors.

I found a free script showing equivalent pantone color from the link blow.

10 Free and Extremely Useful Illustrator Scripts - Vectips

And trying to tweak to make the pantone color to be applied to the selected object.

In below script, I added line 178 and 179 like below.

activeDocument.selection[0].fillColor.typename = "SpotColor";
activeDocument.selection[0].fillColor.color = matchlist[0];

But it doesn't change the object's color.

Could you let me know how to do this?

I am not sure how to add script in this forum. Please download JS code from the link below.

https://www.dropbox.com/sh/qdxo1pi482h6yyx/AACeeo-ko6-ZPlzwfzpjZZQaa?dl=0

I am kind of new to scripting and wondering how to make this work.

If anyone can give me some advice, it would be great.

Thank you.

This topic has been closed for replies.
Correct answer Qwertyfly___

I can't see that being an issue.

moving things to new layers based on their colour should not be hard.

but it will mess with your stacking order!

I would look at doing it right.

create a new doc, delete all swatches, add all PMS swatches from desired colorbook

this can be used to change the colours to the PMS swatch that it best matches

the Wundes script works only on the first item in selection.

you will need to make that a loop of all pathItems.

it also only checks the fill, and not the stroke.

a few more lines of code can fix that.

you will also want to remove the "do you want to use pastels" dialog. and all other dialogs...

you may also want to automate an increasing prec (precision) until it finds a match.

depending on what you want this for it may also pay to export all this info to a text doc so you can find any colours that are a poor match etc.

as you can see there is a few hours of messing around to tweak the script to do what you want.

and I am happy to help out with some of it.

give us some more info about how the final result is being used. I don't want to wast time on features that are not needed.


here is a bit of a start.

still does not do strokes.

still can fail badly in some cases.

it's using the "PANTONE+ Color Bridge Coated" color book.

this was loaded into the PMS.ai file

save the .ai file in the same directory as the script file.

this should give you a good place to get started.

qwertyfly.com/files/scripts/PMS.zip

1 reply

Qwertyfly___
Legend
January 31, 2016

I used to use this script a bit. it has not been updated in a long time so is missing many of the newer PMS colors, and I believe pantone has modified many of the CMYK breakdowns over the past few years.

that said it should still give decent results if you don't need to be too accurate.

if you look at the code, Wunds has included all the swatch names and all the breakdown for CMYK and RGB.

it does not access a swatchbook in illustrator.

this makes it much more then an added few lines here and there to get it to recolor automatically.

in illustrator we don't have access to external swatch books from Javascript.

a workaround to that is to save a document that has all the Pantone colors added to it's swatch pallet, then you can access them from there.

this thread has some info on the topic. How do I script Illustrator to get a PANTONE swatch from a swatch library

there is a built in function of the recolor Artwork Dialog that will convert colors to Pantone, but this is not scriptable with JS.

it could be done using VB Script with a few SendKey statements, not ideal but could work...

sdfasgdgAuthor
Participant
February 1, 2016

Thanks Qwertyfly,

It sounds like adding pantone color is more difficult than I thought,

as an alternative, I am wondering if we can put the object in to the layer that has the name of pantone color?

For this, I think,

1) select 1 object and run above script to find out the pantone color name

2) take the first pantone color name ( which I think "matchlist[0]" at line 162 )

3) creating a layer with the name of the pantone color name (matchlist[0]) if it is not already exist.

4) select all objects with the same fill color.

5) move all selected object into the layer with the name of the pantone color.

Could you let me know if this is feasible to think about? or could you help on coding for this?

Thanks a lot.

Qwertyfly___
Legend
February 1, 2016

I can't see that being an issue.

moving things to new layers based on their colour should not be hard.

but it will mess with your stacking order!

I would look at doing it right.

create a new doc, delete all swatches, add all PMS swatches from desired colorbook

this can be used to change the colours to the PMS swatch that it best matches

the Wundes script works only on the first item in selection.

you will need to make that a loop of all pathItems.

it also only checks the fill, and not the stroke.

a few more lines of code can fix that.

you will also want to remove the "do you want to use pastels" dialog. and all other dialogs...

you may also want to automate an increasing prec (precision) until it finds a match.

depending on what you want this for it may also pay to export all this info to a text doc so you can find any colours that are a poor match etc.

as you can see there is a few hours of messing around to tweak the script to do what you want.

and I am happy to help out with some of it.

give us some more info about how the final result is being used. I don't want to wast time on features that are not needed.