Colors and QuarkXPress 6.5

I’m having trouble manipulating the colors in Quark documents. I have a large batch of files that were built poorly, using a mix of RGB, CMYK and Pantone Spot colors.

What I need is a script that will

  1. go through the colors
  2. delete colors that are not in use
  3. change RGB and Pantone colors to CMYK and
  4. rename them all based on their CMYK values in the format “C M Y K” where each letter is a 0 to 100 value.

But I’m completely lost on what the syntax is to address these. Even my super-simple code below gives me an error I don’t know how to get around. (QuarkXPress got an error: Can’t get CMYK color value of item 1 of every color spec of document 1.)

Any push in the right direction would be much appreciated


tell application "QuarkXPress"
	activate
	tell document 1
		repeat with i in color specs
			set colorName to CMYK color value of i
			display dialog colorName
		end repeat
	end tell
end tell

Model: PowerMac G5
AppleScript: 1.10.7
Browser: Firefox 3.6.12
Operating System: Mac OS X (10.4)

Hi,

try something like this … (could only code it for QXP 8.16)


tell application "QuarkXPress"
	activate
	tell document 1
		set EveryColor to every color spec
		repeat with i from 1 to count of EveryColor
			set theColor to item i of EveryColor
			
			--quick'n dirty ...
			try
				tell theColor
					set lock to false
					set color type to CMYK type
					set {c, m, y, k} to CMYK color value
					set cmykVal to my getVal(c, m, y, k)
					set name to cmykVal
					set separation to true
				end tell
			end try
			
		end repeat
	end tell
end tell


--need to calculate here, 'cause QXP shows the colour value of 100 percent
--as 65535. I guess it's the count of colours which are possible in a 16bit -system. 
--2^16 = 65536 :)
on getVal(c, m, y, k)
	set cV to ((c / 655.36) div 1) as text
	set mV to ((m / 655.36) div 1) as text
	set yV to ((y / 655.36) div 1) as text
	set kV to ((k / 655.36) div 1) as text
	return "C" & cV & " M" & mV & " Y" & yV & " BK" & kV
	end getVal

Thanks. That mostly worked. I had to add an if/then clause to exclude the Registration around the “tell theColor” block. Also, this didn’t convert any Pantone colors, but upon further study of the Quark library, I’m not even sure that’s possible, as there seems to be no way to define or address a Pantone color at all. That’s not really too big a deal as most of the time, it’s just one or two in each document and I can convert them to CMYK before I run the script. This will all get worked into a larger script that checks style sheets, screen position and a handful of other things as well.

From the Quark library:

Again, thanks for the push in the right direction. I’m pretty sure I have a decent idea of how to proceed.

Interesting tidbit: The script above often, but not always returns a value one digit lower than the actual value for CMYK when naming. For instance, I just ran it on a file with a CMYK color of 0, 55, 100, 0 and it named the color 0 54 99 0. I’m not really great at math, so it will probably take me a while to figure out why it’s doing that. I just thought it was interesting enough to bring up.

It seems to have been a rounding error in the “div 1” statement. The code below appears to have fixed the problem.


on getVal(c, m, y, k)
	set cV to (round (c / 655.36)) as text
	set mV to (round (m / 655.36)) as text
	set yV to (round (y / 655.36)) as text
	set kV to (round (k / 655.36)) as text
	return cV & " " & mV & " " & yV & " " & kV
end getVal

Hi,

the “round” will be exacter, your right.

In 8.1.6 the script changes Pantone Spotcolors too, but you have to change the try block a little bit …
First set the separation to true and then speak about cmyk … I’m sorry :wink:

--quick'n dirty ...
			try
				tell theColor
					set lock to false
					set separation to true
					set color type to CMYK type
					set {c, m, y, k} to CMYK color value
					set cmykVal to my getVal(c, m, y, k)
					set name to cmykVal
				end tell
			end try

I’ll try that once I get into work. Thanks again for your help.

Well, your suggestion still left the Pantone, Trumatch, TOYO, FOCALTONE and DIC colors intact. However, if I specified a change to LAB first, and then CMYK, everything started coming up Milhouse.


if name of theColor is not "Registration" then
					tell theColor
						set lock to false
						set separation to true
						set color type to LAB type
						set separation to true
						set color type to CMYK type
						set {c, m, y, k} to CMYK color value
						set cmykVal to my getVal(c, m, y, k)
						set name to cmykVal
					end tell
				end if