Scripting Illustrator CS - more about compound path

Ok. So I figured out basically how to make a compound path in Illustrator CS (11.0.0) on OS 10.3.5. The problem is that when the path is made it does not act like a compound path made by “hand”. The path ends up being a square with no fill color. What I want (and can do manually) if to have a rectangle with a rectangular hole in it. (Not a rectangle with another in front with a white fill. This won’t work for my purposes.) Anyway, here’s the code I came up with. Can anyone explain why this doesn’t work the way I’d like it to?

tell application "Illustrator CS"
	activate
	set pathRef to make new document
	set this_doc to current document
	set groupref to make new compound path item in document 1
	set recRef to make new rectangle at beginning of groupref with properties {name:"rec1", position:{100, 400}, width:{200}, height:{200}, fill color:{black:100}, stroke color:{class:no color info}}
	set recRef to make new rectangle after recRef with properties {name:"rec2", position:{125, 375}, width:{150}, height:{150}, fill color:{class:no color info}, stroke color:{class:no color info}}
end tell

I don’t know if you figured this out yet, but a couple tweaks to your code and it works great. The changes I made were to give your second rectangle a fill of black, and to set the polarity of that rectangle to negative. This allows it to be “see through”, much like changing the path direction in the Attributes pallette of the interface.


set groupref to make new compound path item in document 1
set recRef to make new rectangle at beginning of groupref with properties {name:"rec1", position:{100, 400}, width:{200}, height:{200}, fill color:{black:100.0}, stroke color:{class:no color info}}
set recRef to make new rectangle after recRef with properties {name:"rec2", position:{125, 375}, width:{150}, height:{150}, fill color:{black:100.0}, stroke color:{class:no color info}, polarity:negative}

Thanks! I hadn’t found that yet.