: Illustrator Script to Release All Clipping Masks & Groupings, Etc. Is there a script available for Illustrator that would allow for all clipping masks, groupings and compound paths to be released?
Is there a script available for Illustrator that would allow for all clipping masks, groupings and compound paths to be released? Essentially a script that could breakdown a file to it's original parts.
More posts by @Courtney577
4 Comments
Sorted by latest first Latest Oldest Best
You don't need a script to release all clipping mask in one step, just do:
Select->Object->Clipping Mask
Edit->Clear
But it can also be done via script:
app.executeMenuCommand("Clipping Masks menu item");
app.executeMenuCommand("clear");
The same for ungroupping all objects and release all compound paths:
app.executeMenuCommand("selectall");
app.executeMenuCommand("ungroup");
app.executeMenuCommand("noCompoundPath");
Here you go (this is not super thoroughly tested if it has a bug let me know abd i will support you):
#target illustrator
// releaseEverything.jsx
//
// Copyright (c) 2017 Janne Ojala
//
// Licence: opensource.org/licenses/MIT
(function(){
var objs = app.activeDocument.pageItems;
// or if you want only selection use app.activeDocument.selection
traverseSceneObjects(objs);
function traverseSceneObjects(pageItems){
for (var iter=0 ; iter<pageItems.length; iter++ ){
var item = pageItems[iter];
var typename = item.typename;
// apply action or get the subitems of object
if (typename === "PathItem"){
item.clipping = false;
} else if (typename === "GroupItem") {
traverseSceneObjects( item.pageItems );
release( item, "pageItems" );
} else if (typename === "CompoundPathItem" ) {
traverseSceneObjects( item.pathItems );
release( item, "pathItems" );
}
}
}
function release(obj, action) {
for (var i=obj[action].length-1 ; i>=0; i--){
obj[action][i].move( obj, ElementPlacement.PLACEAFTER );
}
}
})();
However personally I would not use this kind of thing. Doing selective flattening in better and has more synergy benefits.
Note: This applies to entire file. if you want it to only apply to a selection change the line var objs = app.activeDocument.pageItems; to var objs = app.activeDocument.selection;
Here is a script to Remove all clipping masks in a file.
Perhaps if you replaced .remove with .release it will perform your desired function.
forums.adobe.com/thread/287643
I don't think it's that difficult to use the key commands CMD-A and CMD-8 alternately as much as needed, but if you want you can throw 10 iterations in an action and play it as much as needed.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.