In Adobe Illustrator CS I’m trying (as part of a bigger script) to select everything in a document and make a clipping path.
I’m probably overlooking something very obvious, but
A: I can’t find how to select everything in a document (the direct way. There are ways to make a list of all items in a file and than selecting these items one at a time, but I’m looking for the “one command” (applekey-A) option).
Edit: I figured out the select all option: “set selection to every page item of every layer”. But still no joy on the clipping path (see below)
B: The dictionary doesn’t mention anything about making a clipping path (applekey-7), so I’m in the dark here about the possibility of doing this at all with Applescript.
Ton -
Take a look in the dictionary under Path Item - there is a “clipping” property that sets whether the specified path item is to be used as a clipping path. If that approach doesn’t come together, try setting up an action to create the clipping path and call the action from your script.
I tried fiddling with the clipping property, but it doesn’t work straightforward. It’s possible to ask for for the state, but setting it doesn’t seem to have any effect (after setting, checking for the state will still return false).
Using an action is also not really an option, because the script is used all over my department and this would mean installing actions on all individual computers.
The current working solution is to use the System Events to make a keystroke:
tell application "System Events" to keystroke "7" using {command down}
martovarot, this works for me by moving all the page items into a group item then setting the clipping of the group item to true. The clipping one is the uppermost item of the page items moved into the group item. Only performed a basic test but hope it helps.
tell application "Illustrator CS"
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
When you think about the selection tools in the application once you have used “comm+7” to make your clipping mask the objects behave as a group. In script it appears that the group needs to be made first then activate its clipping to the top most object. Not sure if you would need to put some catches in first to find things that may not work with a little more playing I found that existing groups moved into the new group caused an error. This would all depend on the contents of you files I think but then I am fairly new to this. Glad to have been of some all be it limited assistance…