I’ve run across a glitch and was wondering if anyone could help out. If I were to draw a box in Illustrator and fill it with a gradient swatch, when my script (see below) runs, the box turns black and the class is changed from “Gradient Color Info” to “Grayscale Color Info”. If I were to manually delete the swatch through Illustrator, there’s no problems and the box retains it’s gradient. It seems that using the “Delete Swatch” command through applescript changes the class. Has anyone else encountered this, or maybe know how to get around it? Any help would be appreciated!
Here is the code:
tell application "Adobe Illustrator"
activate
set docRef to document 1
tell docRef
set swatchCount to get count of swatches
set deleteList to {}
repeat with i from 1 to swatchCount
set colorType to color of swatch i
set colorClass to class of colorType
set colorName to name of swatch i
--finds 4-CP
if colorClass is CMYK color info then
set end of deleteList to colorName
end if
--finds gradients
if colorClass is gradient color info then
set end of deleteList to colorName
end if
--finds patterns
if colorClass is pattern color info then
set end of deleteList to colorName
end if
--excludes spot colors
if colorClass is spot color info then
end if
--excludes "none"
if colorClass is no color info then
end if
end repeat
set deleteCount to count of items in deleteList
--return deleteList
repeat with x from 1 to deleteCount
set deleteThisSwatch to item x of deleteList
delete swatch deleteThisSwatch
end repeat
end tell
end tell