Skip to main content
Known Participant
September 19, 2023
Answered

InDesign script to convert Spots to CMYK - except one.

  • September 19, 2023
  • 1 reply
  • 1038 views

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.

This topic has been closed for replies.
Correct answer Robert at ID-Tasker

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

 

 

1 reply

Known Participant
September 20, 2023

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.
Robert at ID-Tasker
Robert at ID-TaskerCorrect answer
Legend
September 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

 

 

Known Participant
September 21, 2023

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.