Scripting Illustrator CS

Hi. Fairly new to scripting and new to Illustrator CS scripting. I’ve found some usefull info here and at the adobe site but cannot figure this out so far. I’ve written a script to create a rectangle. When I create the rectangle I want it to have a certain fill color. I can get it to fill with CMYK but cannot get it to fill with a spot color or with a certain tint value (50%). Can anyone give me the basic syntax for this?

This works for me:

-- Make a new spot with name and color properties 
tell application "Illustrator CS"
	-- set up the appropriate color record for the document color space 
	set docColorSpace to color space of document 1
	if (docColorSpace is CMYK) then
		set newSpotColor to {cyan:25.0, magenta:75.0, yellow:0.0, black:0.0}
		set newSpotColor to {red:255.0, green:0.0, blue:25.0}
	end if
	-- now create the new spot 
	make new spot in document 1 with properties {name:"My Spot", color:newSpotColor}
	--make rectangle with fill color "my Spot" 
	set pathRef to make new rectangle at beginning of document 1 ¬
		with properties {bounds:{155.0, 480.0, 370.0, 240.0}, note:"square", fill color:{class:spot color info, tint:50.0, spot:spot "My Spot" of document 1}}
end tell

Thanks MarcoP. I’ll give that a try. Maybe you could answer one other question? If I want to use a pantone spot color do I need to get its CMYK values and create it from within the script or can I reference a specific pantone color?

Your help is much appreciated!!! :lol: :lol: :lol: :lol:

Your welcome Pretech :stuck_out_tongue:

I don’t have an excact answer for your new question. But one thing that works is to select manually the pantone swatches you need (or all) in the pantone swatches library and add them to your main color swatches pallet.
than this will work:
set the fill color of page item 1 of document 1 to {class:spot color info, tint:20.0, spot:spot “PANTONE 9040 C” of document 1}

For as far as I know/tried the (spot)color name reference works only in the main swatches pallet.

Hope this will help you a little

Also make sure to specify a tint property value, even if you want 100%. While you might assume that it defaults to 100% if not specified, actually it will simply fail to apply the color at all. The error messages you receive will not lead you to the source of the problem right away…