Copy link to clipboard
Copied
Is there a way to use scripts to set the CMYK value of a color swatch? Say I have a swatch named "Color 1," can I use scripts to set the CMYK (or RGB) values for that swatch?
app.activeDocument.colors.item("Color 1").colorValue = [0,20,80,0];
Copy link to clipboard
Copied
If you don't get an answer here, ask in the InDesign Scripting forum:
Copy link to clipboard
Copied
This javascript 3-liner will convert your RGB swatches to CMYK:
for (c=0; c<app.activeDocument.colors.length; c++)
if (app.activeDocument.colors
.space == ColorSpace.rgb) app.activeDocument.colors
.space = ColorSpace.cmyk;
Copy link to clipboard
Copied
No, I don't want to convert CMYK to RGB. I want to change the CMYK value of a current swatch
Copy link to clipboard
Copied
Well, look at this thread then. Pretty old, but scripts from there still should do the trick.
Copy link to clipboard
Copied
Discussion Moved to InDesign Scripting​
Copy link to clipboard
Copied
app.activeDocument.colors.item("Color 1").colorValue = [0,20,80,0];
Copy link to clipboard
Copied
Thank you typolis​ it worked perfectly!
Copy link to clipboard
Copied
hi typolis! is there a way to find the value itself instead of the values name?
so instead of "Color 1" I would look for the CMYK-colorValue of "Color 1"?
Copy link to clipboard
Copied
var colorValueArray = app.activeDocument.colors.item("Color 1").colorValue;
alert( colorValueArray.join(","));
Hi Julia,
method array.join("SeparatorString") will convert the array with the numbers to a string so that you can alert it.
Note: If colorValue array holds three numbers you cannot be sure if the numbers mean RGB or Lab numbers.
So look up the DOM documentation and check what properties are available for object color:
Properties model and space will tell you more. The numbers alone could be misleading:
Adobe InDesign CS6 (8.0) Object Model JS: Color
Regards,
Uwe
Find more inspiration, events, and resources on the new Adobe Community
Explore Now