Fill Illustrator Compound Path with Apple Script


after just reading and learning a lot of Apple Script. I tried to make a a script to change the color of compound path items. But it looks like that it doesn’t work.

I get an Error “„Adobe Illustrator“ hat einen Fehler erhalten: „every compound path item of document 1 whose filled = true“ kann nicht als „{class:spot color info, tint:100.0, spot:spot 1 of document 1}“ gesetzt werden.”

Maybe there is someone who solved this problem alreadys or may help me.

tell application "Adobe Illustrator"
	tell document 1
		set LayerCut to "Reg"
		set SpotColor to color of swatch "Spot Color"
		set (fill color of every compound path item whose filled is true) to SpotColor
	end tell
end tell


Model: iMac
AppleScript: 2.7
Browser: Safari 537.36
Operating System: macOS 10.13

Hi. Compound paths have no color property; their color comes from constituent path items.

tell application "Adobe Illustrator"'s document 1
	set chosenSpot to spot "Spot Color"'s color 
	repeat with counter from 1 to count compound path items
		set compound path item counter's path item 1's fill color to chosenSpot
	end repeat
end tell

edit: The loop and variabilization aren’t technically necessary. This is simpler, although it isn’t error trapped against the user cancelling without selecting a spot choice.

tell application "Adobe Illustrator"'s document 1 to set compound path items's path item 1's fill color to (swatch ((choose from list (get spots's name))'s item 1)'s color)

Thank you Marc, that’s it!