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

Script to convert CMYK color to PMS color

Community Beginner ,
Jan 28, 2016 Jan 28, 2016

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

6.0K

Translate

Translate

Report

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

correct answers 1 Correct answer

Guide , Feb 01, 2016 Feb 01, 2016

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

Votes

Translate

Translate
Adobe
Guide ,
Jan 31, 2016 Jan 31, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Community Beginner ,
Feb 01, 2016 Feb 01, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 01, 2016 Feb 01, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 01, 2016 Feb 01, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Community Beginner ,
Feb 01, 2016 Feb 01, 2016

Copy link to clipboard

Copied

Thanks a lot Qwerty.

The concept of swatch book was new to me and a bit confused.

But I believe I get the idea and will take a look and try to make it work.

Votes

Translate

Translate

Report

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 01, 2016 Feb 01, 2016

Copy link to clipboard

Copied

cool, like I said, let me know if I can help you out some more.

with JS in illustrator we don't have access to swatch books.

but we do have access to the document swatches.

the PMS.ai file I made.

all I did was move all the colors from the "Pantone+ Color Bridge coated" in to the document swatches then save it.

then we can access the swatches from that document...

I used the color bridge as this swatch book has colors like Process Cyan C, unlike the newer Solid Coated V2 book. (I think they even have a newer one now)

just as a note.

if you are looking for what I have changed.

all changes I made have comments to show what I did.

ie.

// QF - now we open the document with all the PMS swatches in it.

Votes

Translate

Translate

Report

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 01, 2016 Feb 01, 2016

Copy link to clipboard

Copied

so is this kinda doing what you wanted?

if so, I'm glad I could help.

sing out if you get stuck finishing it off.

Votes

Translate

Translate

Report

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
Community Beginner ,
Jul 24, 2022 Jul 24, 2022

Copy link to clipboard

Copied

The URL that you provided is not accessible anymore can you please update the URL?

Votes

Translate

Translate

Report

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 ,
Jul 24, 2022 Jul 24, 2022

Copy link to clipboard

Copied

LATEST

Votes

Translate

Translate

Report

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