I need to mask objects in illustrator …
I can do this using GUI scripting but it takes too long.
Does anybody know how to make a mask without using GUI scripting
thanks
mm
I need to mask objects in illustrator …
I can do this using GUI scripting but it takes too long.
Does anybody know how to make a mask without using GUI scripting
thanks
mm
Hi mm
To script a mask in illustrator
you need to make the objects you want masking into a group then say create a rectangle at the beginning of that group.
then “set clipped of that group to true” an d that should do it!!
sorry to be a bit vague but it can be done without GUI i’ll try and dig something out i have!
try this
tell application "Adobe Illustrator"
activate
set g to make new group item at end of layer 1 of document 1
set t to make new star in document 1
set p to position of t
set f to make new ellipse in document 1 with properties {position:p}
move every path item of layer 1 of document 1 to end of g
set clipped of g to true
end tell
With objects already made and top item your path item to use as mask it’s as straight forward as
tell application "Adobe Illustrator"
tell document 1
set MyStuff to every page item
set MyGroup to make new group item at beginning
move MyStuff to beginning of MyGroup
set properties of MyGroup to {clipped:true}
end tell
end tell
a note of caution if you require moving this group later that the visual bounds does not appear to calculate correct with masked groups.
WOW thank you both thats awesome!!!
Ok this is cool but for some reason it won’t work with a compound path as the top object ?
mm
anyone have any ideas on how I can make the masking work with a compound path item as the top most object in the group
mm
Hi mm
I think you may have hit on something there, i’m struggling to get it to work as well.
Maybe a bug.
You might need to go down the GUI route to get the result your after unless someone else has the answer.
pidge1
I actually got it to work after making some hoops. I have it working in my script but now I’m having trouble simplifying it so I can post it here basically you have to make a temp item set the group to clipped then set clipping of every path item of the compound path then delete the temp item. But I’ll post it here soon
mm
Hi mm
Strangely enough i got this working for me must have just been the way i set the file up.
i had a couple of compound paths in my do then run this it worked fine:
tell application "Adobe Illustrator"
activate
set g to make new group item at beginning of document 1
set t to make new star at beginning of document 1 with properties {position:{200, 1000}}
move every path item of document 1 to beginning of g
set clipped of g to true
end tell
pidge1
I think that is because you are making the star the mask; correct ?
mm
Hi mm
Yes correct!
By the sounds of your post i guess i’ve got the wrong end of the stick??
if you mean the compound path as the mask then the result i get is the top most path item within the compound path is turned into the mask.
pidge1
yeah, I’m trying to create the mask using the compound path as the mask item, so if you where to continue on with what you have like this
tell application “Adobe Illustrator”
activate
set g to make new group item at beginning of document 1
set t to make new star at beginning of document 1 with properties {position:{200, 1000}}
move every path item of document 1 to beginning of g
set clipped of g to true
set clipping of path items of first compound path item of g to true
delete t
end tell
it should work! but you shouldn’t have to make a temp item to do this.
mm
edit: Your compound path must not contain any groups
Hi Mike
I get varying results with all these different scripts in this thread and they all work! in one way or another so i’ve kinda lost track what was
initially wanted, but if this works for your purposes then good.