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

InDesign script to convert Spots to CMYK - except one.

Explorer ,
Sep 19, 2023 Sep 19, 2023

Copy link to clipboard

Copied

I found a close script on another site which works in the most recent version of InDesign. It's a culmination of 2 users posts, Jongware and Masood Ahmad, so credit to them. It removes unused colours, adds unnamed colours and converts all to CMYK:

#target indesign
app.menuActions.item("$ID/Add All Unnamed Colors").invoke();
var myIndesignDoc = app.activeDocument;
var myUnusedSwatches = myIndesignDoc.unusedSwatches;
for (var s = myUnusedSwatches.length-1; s >= 0; s--) {
var mySwatch = myIndesignDoc.unusedSwatches[s];
var name = mySwatch.name;
if (name != ""){
mySwatch.remove();
}
}
app.activeDocument.colors.everyItem().properties = {space:ColorSpace.CMYK, model:ColorModel.PROCESS};

 

Further to this, I'd like to ask if anyone knows how to keep a particular colour as a spot, say for example the colour CUTTER. Currently I have to convert all the colours with this script then go back and make the CUTTER a spot again, so I'd like a failsafe way for myself and the junior team members to avoid any issues when sending print files to production.

Appreciate any help.

TOPICS
Print , Scripting

Views

308

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

Community Expert , Sep 20, 2023 Sep 20, 2023

I'm not JS guy so you need to test it further:

 

app.activeDocument.colors.item("CUTTER").model = ColorModel.SPOT;

 

or something like that - you just need to get a reference to your color - and then change its color model.

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Color.html#d1e68975

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ColorModel.html

 

 

Votes

Translate

Translate
Explorer ,
Sep 20, 2023 Sep 20, 2023

Copy link to clipboard

Copied

I have made some headway with this by adding this line to the bottom:

{app.activeDocument.colors.add({ colorValue : [0,100,0,0], name : "CUTTER", model:ColorModel.SPOT });};

This works a treat when the colour is not already in the swatch pallete. If it is, however, then I get the error shown below (Swatch name already in use, please choose another)
My scripting knowledge is limited to using other scripts and trying to logically change to suit, so any help would be most welcomed.

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 Expert ,
Sep 20, 2023 Sep 20, 2023

Copy link to clipboard

Copied

I'm not JS guy so you need to test it further:

 

app.activeDocument.colors.item("CUTTER").model = ColorModel.SPOT;

 

or something like that - you just need to get a reference to your color - and then change its color model.

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Color.html#d1e68975

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ColorModel.html

 

 

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
Explorer ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

You beauty! Thank you Robert, you are a star.
As I said, my JS is very limited, but this worked - 95%. It did throw up another issue if the colour wasn't present in the swatches, but using another script I had, I managed to fix it by adding the colour before the conversion.
So now the full script is this:

#target indesign
app.menuActions.item("$ID/Add All Unnamed Colors").invoke();
var myIndesignDoc = app.activeDocument;
var myUnusedSwatches = myIndesignDoc.unusedSwatches;
for (var s = myUnusedSwatches.length-1; s >= 0; s--) {
var mySwatch = myIndesignDoc.unusedSwatches[s];
var name = mySwatch.name;
if (name != ""){
mySwatch.remove();
}
}
var myColorToCheck = app.activeDocument.colors.itemByName("CUTTER");
if(!myColorToCheck.isValid){app.activeDocument.colors.add({ colorValue : [0,100,0,0], name : "CUTTER" });};
app.activeDocument.colors.everyItem().properties = {space:ColorSpace.CMYK, model:ColorModel.PROCESS};
app.activeDocument.colors.item("CUTTER").model = ColorModel.SPOT;

 I knew this community would come good.

Thank you again!

Andy.

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 Expert ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

You are welcome. 

 

You can make it a bit more "optimal" - move "if" after the conversion of all colors - and do it as "if...else...".

 

If (exists) then (convert back) else (create)

 

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
New Here ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

Hi All,

 

I too am new to scripting. I used this, but is there a way to change spot colors brought in by logos?

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
Explorer ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

If the logo is an external link, then the only way I know of is in Ink Manager.

You can assign the logo spot colour to a new spot colour of your making with the changed CMYK breakdown.
Then when the document is converted to CMYK, it will have the desired colour.

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
New Here ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

Thank you for your response, I knew that, I was looking for way to script Ink Manager.

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 Expert ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

This would set all spots to process in Ink Manager:

 

app.activeDocument.inks.everyItem().convertToProcess = true

 

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
New Here ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

LATEST

Thank you Rob!!

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 Expert ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

Hi @Michael26883498wn3q , A Spot color swatch that comes in with a placed file can be changed to Process, but its Color Mode can’t be changed via the UI or scripting—if the Color Mode is Lab it can’t be set to CMYK. You  can use Ink Manager (or Inks in scripting) to convert Spot Colors to process, or you can leave the color as Lab and let a color managed conversion to CMYK happen on Export by setting a CMYK Destination in the Output tab.

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
New Here ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

OK, but can I use a script to change the colors in ink manager?

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