Skip to main content
Participant
December 14, 2010
Question

How to make a spot swatch with specific name by using AppleScript?

  • December 14, 2010
  • 3 replies
  • 2724 views

Hi there,

I am trying to create a script in AppleScript to make a new spot color swatch that must be the COLOR TYPE : SPOT (with specific values). I've got it to make a global process color but can't seem to make a spot swatch. I'm using the script below :

tell application "Adobe Illustrator"
    set docColorSpace to color space of document 1
    if (docColorSpace is CMYK) then
        set SpotColor to {cyan:100.0, magenta:0, yellow:0.0, black:0.0}
    else
        set SpotColor to {red:0.0, green:174.0, blue:239.0}
    end if
    make new spot in document 1 with properties {name:"ADHESIVE", color:SpotColor}
end tell

I did find an entry in an old forum that did this using javascript, however, I am not experienced with this at all and have no idea what or how to use it on a mac platform. This script is listed below.

#target illustrator

var docRef = app.activeDocument;

var newCMYK = new CMYKColor();
newCMYK.cyan = 100;
newCMYK.magenta = 0;
newCMYK.yellow = 0;
newCMYK.black = 0;

var thisSpot = docRef.spots.add();
thisSpot.name = 'ADHESIVE';
thisSpot.color = newCMYK;
thisSpot.colorType = ColorModel.SPOT;

Any help would be greatly appreciated.

Thank you!

This topic has been closed for replies.

3 replies

Participant
December 15, 2010

Beautiful; thank you both!

Larry G. Schneider
Community Expert
Community Expert
December 14, 2010

tell application "Adobe Illustrator"

    set docColorSpace to color space of document 1

    if (docColorSpace is CMYK) then

        set SpotColor to {cyan:100.0, magenta:0, yellow:0.0, black:0.0}

    else

        set SpotColor to {red:0.0, green:174.0, blue:239.0}

    end if

    make new spot in document 1 with properties {name:"ADHESIVE",

color type:spot color,

color:SpotColor}
end tellt
Muppet_Mark-QAl63s
Inspiring
December 14, 2010

You are close but missing the last property listed in the JavaScript… It translates to… 'color type:spot color'

tell application "Adobe Illustrator"

set docColorSpace to color space of document 1

if (docColorSpace is CMYK) then

set SpotColor to {cyan:100.0, magenta:0, yellow:0.0, black:0.0}

else

set SpotColor to {red:0.0, green:174.0, blue:239.0}

end if

make new spot in document 1 with properties {name:"ADHESIVE", color:SpotColor, color type:spot color}

end tell

BTW… The use of JavaScript in the CS apps is more common because of its 'platform independence' There is a toolkit supplied along with the CS install.