Tuesday, August 11, 2020

#1 2013-11-13 09:38:45 pm

sudno
Member
Registered: 2007-02-01
Posts: 20

Indesign CS6 - Rename all colors with color value

Hello!

I'm looking to create a simple script to select all unused colors, remove them, convert all spot colors to process CMYK and then rename all swatches that are left with their color value.  I have the first two covered but I'm struggling finding anything on how to rename the colors by the color value (CMYK mix).

Script so far:

Applescript:

tell application "Adobe InDesign CS6"
   tell document 1
       set model of every color whose model is spot to process
       delete unused swatches
       --fail below
       --set name of every color to color value
   end tell
end tell

Any help would be greatly appreciated....thank you very much.

Sudno

Model: Mac
AppleScript: 2.43
Browser: Firefox 25.0
Operating System: Mac OS X (10.8)


Filed under: Indesign, color value

Offline

 

#2 2013-11-13 10:42:40 pm

sudno
Member
Registered: 2007-02-01
Posts: 20

Re: Indesign CS6 - Rename all colors with color value

I have gotten a little bit further but the script is only renaming one swatch..hmmm

Update:

Applescript:

tell application "Adobe InDesign CS6"
   tell document 1
       delete unused swatches
       set allSwatches to every swatch
       set swatchCount to count of allSwatches
       set thisSwatch to item swatchCount of allSwatches
       set swatchColor to color value of thisSwatch
       set ccc to ((item 1 of swatchColor) as integer)
       set mmm to ((item 2 of swatchColor) as integer)
       set yyy to ((item 3 of swatchColor) as integer)
       set kkk to ((item 4 of swatchColor) as integer)
       set swatchMix to ("C-" & ccc & " M-" & mmm & " Y-" & yyy & " K-" & kkk) as string
       repeat with i from 1 to count of colors
           try
               set properties of color i to {space:CMYK, model:process, name:swatchMix}
           end try
       end repeat
   end tell
end tell

Thanks again in advance,

Sudno

Offline

 

#3 2013-11-13 11:45:28 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6436

Re: Indesign CS6 - Rename all colors with color value

Try this:

Applescript:

tell application "Adobe InDesign CS6"
   tell document 1
       delete unused swatches
       set allSwatches to every swatch
       set swatchCount to count of allSwatches
       repeat with i from 1 to swatchCount
           set thisSwatch to item i of allSwatches
           set swatchColor to color value of thisSwatch
           set ccc to ((item 1 of swatchColor) as integer)
           set mmm to ((item 2 of swatchColor) as integer)
           set yyy to ((item 3 of swatchColor) as integer)
           set kkk to ((item 4 of swatchColor) as integer)
           set swatchMix to ("C-" & ccc & " M-" & mmm & " Y-" & yyy & " K-" & kkk) as string
           try
               set properties of color i to {space:CMYK, model:process, name:swatchMix}
           end try
       end repeat
   end tell
end tell


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#4 2013-11-13 11:51:13 pm

sudno
Member
Registered: 2007-02-01
Posts: 20

Re: Indesign CS6 - Rename all colors with color value

Hey Shane,

Thank you so much for responding... I'm now getting the following error when running your script:

Adobe InDesign CS6 got an error: Can’t get color value of swatch id 14 of document id 14.

Thoughts?

Offline

 

#5 2013-11-14 12:00:16 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6436

Re: Indesign CS6 - Rename all colors with color value

Not all swatches have color values -- color "None" is swatch id 14. So you need to check for that (and for any RGB colours, because they won't have four values for color value).

Try this:

Applescript:

tell application "Adobe InDesign CS6"
   tell document 1
       delete unused swatches
       set allSwatches to every swatch
       set swatchCount to count of allSwatches
       repeat with i from 1 to swatchCount
           set thisSwatch to item i of allSwatches
           if name of thisSwatch is not "None" and space of thisSwatch is CMYK then
               set swatchColor to color value of thisSwatch
               set ccc to ((item 1 of swatchColor) as integer)
               set mmm to ((item 2 of swatchColor) as integer)
               set yyy to ((item 3 of swatchColor) as integer)
               set kkk to ((item 4 of swatchColor) as integer)
               set swatchMix to ("C-" & ccc & " M-" & mmm & " Y-" & yyy & " K-" & kkk) as string
               set properties of swatch i to {space:CMYK, model:process, name:swatchMix}
           end if
       end repeat
   end tell
end tell


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#6 2013-11-14 08:49:49 am

sudno
Member
Registered: 2007-02-01
Posts: 20

Re: Indesign CS6 - Rename all colors with color value

Hi Shane,

Thank you very much!  It's not picking up all of the colors but this works well enough.

I really appreciate your assistance.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)