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

InDesign Scripts - Color Swatch

Community Beginner ,
Feb 05, 2019 Feb 05, 2019

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?

TOPICS
Scripting
6.8K
Translate
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 Beginner , Feb 06, 2019 Feb 06, 2019

app.activeDocument.colors.item("Color 1").colorValue = [0,20,80,0];

Translate
Community Expert ,
Feb 05, 2019 Feb 05, 2019

If you don't get an answer here, ask in the InDesign Scripting forum:

InDesign Scripting

Translate
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
Mentor ,
Feb 05, 2019 Feb 05, 2019

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;

Translate
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 05, 2019 Feb 05, 2019

No, I don't want to convert CMYK to RGB. I want to change the CMYK value of a current swatch

Translate
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
Mentor ,
Feb 05, 2019 Feb 05, 2019

Well, look at this thread then. Pretty old, but scripts from there still should do the trick.

Translate
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
Adobe Employee ,
Feb 06, 2019 Feb 06, 2019

Discussion Moved to InDesign Scripting​

Translate
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 06, 2019 Feb 06, 2019

app.activeDocument.colors.item("Color 1").colorValue = [0,20,80,0];

Translate
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 07, 2019 Feb 07, 2019

Thank you typolis​ it worked perfectly!

Translate
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 ,
Jun 05, 2019 Jun 05, 2019

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"?

Translate
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 ,
Jun 05, 2019 Jun 05, 2019
LATEST

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

Translate
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