Copy link to clipboard
Copied
Hello,
I am currently scripting for Illustrator CS6. I am fairly new to JavaScript. I was wondering if it is possible for a script to identify all <Clip Group> within the file and for it will run an Action to crop within pathfinder? I have created the Action to crop, but I am unsure as to how to call the action correctly for it to work. Any help on this is greatly appreciated.
It's a little complicated, but mostly because of the order of things, in addition to the basic syntax, etc.
#target illustrator
function test(){
var doc = app.activeDocument;
app.executeMenuCommand("Clipping Masks menu item");
var thisClipItem;
var esc = 50; // make sure to have an escape route for the while statement
while(doc.selection.length != 0 && esc > 0){
esc--;
thisClipItem = doc.selection[0];
doc.selection = null;
thisClipItem.parent.selected = true;
app.doScript("Crop
...Copy link to clipboard
Copied
Hello!
This may be a complicated thing to start out with, but here is how you can select all of the clipping mask objects automatically, after which you can cycle through the document.selection to find each one's parent group and then perform the cropping.
You select the clipping paths with:
app.executeMenuCommand("Clipping Masks menu item");
And, you run your action with:
app.doScript(actionName, setName);
Since the cropping procedure will require that you work on the groups individually, it would change your selection, so you'll have to deal with it however you see fit.
Copy link to clipboard
Copied
HI Silly-V,
Thank you for answering my questions. This is what I have so far. The files that I am currently working with that have a clipping mask is labeled as <Clip Group>. Will I need to identify it somehow so the script below will work? Any examples will help me out a bunch. Thanks again.
#target illustrator
var clippingMask = app.executeMenuCommand("Clipping Masks menu item")
function cropMask(clippingMask){
if(clippingMask.length>0){
app.doScript('Cropify', 'Custom Art Actions')
}
};
Copy link to clipboard
Copied
It's a little complicated, but mostly because of the order of things, in addition to the basic syntax, etc.
#target illustrator
function test(){
var doc = app.activeDocument;
app.executeMenuCommand("Clipping Masks menu item");
var thisClipItem;
var esc = 50; // make sure to have an escape route for the while statement
while(doc.selection.length != 0 && esc > 0){
esc--;
thisClipItem = doc.selection[0];
doc.selection = null;
thisClipItem.parent.selected = true;
app.doScript("CropArt","CropArtSet");
doc.selection = null;
app.executeMenuCommand("Clipping Masks menu item");
}
};
test();
You've got to keep the selection 'juggled' so that the right things are selected when you want them. In this case, we get all of the clipping masks using the selection command, but then in order to use the Crop, we have to deselect all but one of the clipping paths, select the parent group to get the clip and its art both, then use Crop and deselect the result, and then make sure to select the clipping paths again. The while loop is supposed to quit when we are no longer able to select any clipping paths, but in case things go wrong there's an esc variable- right now it's set to 50, make sure this number is larger than your expected clipping paths.
Copy link to clipboard
Copied
This makes so much more sense now. I wasn't aware just how complex something like this can be. Thank you so much for your help!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now