问题
I'm making extend scripts for Adobe Illustrator CS6 (javascript) and I need to delete every clipping masks of a document.
I already have a solution but it's not fast enough in big documents.
Here is my code:
var releaseClippingMasks = function(document) {
var pathItems = document.pathItems;
log('Looking for clipping masks among ' + pathItems.length + ' elements');
var n = 0;
for(var p = pathItems.length - 1; p >= 0; p--) {
if(p / 1000 == Math.round(p / 1000)) {
log(p + ' remaining');
}
if(pathItems[p].clipping) { // accessing to the element [p] of pathItems takes a lot of time
pathItems[p].remove();
n++;
}
}
log(n + ' deleted masks');
}
There are not so many clipping masks in my documents, but a lot of pathItems (100000+), so iterating takes a very long time.
Does anyone know a better way to select every clipping masks in a document by javascript? Any help would be very appreciated.
回答1:
The fastest way to select all clipping mask and delete it:
// Select->Objects->Clipping Mask
app.executeMenuCommand("Clipping Masks menu item");
// Edit->Clear
app.executeMenuCommand("clear");
来源:https://stackoverflow.com/questions/35057879/how-to-select-and-delete-every-clipping-masks-in-an-illustrator-document-using-j