6

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.

  • 2
    Doesn't Select all, Object > Clipping Mask > Release, Object > Ungroup do this? – Scott Sep 1 '15 at 16:41
  • 1
    Yes it does, but the file I am working on has at least 50 instances of clipping mask applied to the file. I am looking for a one click solution to speed up the process. – buzlink Sep 1 '15 at 16:57
  • 1
    Wouldn't putting this in a action suffice? Its easier than scripting and theres no real benefit in scripting this. – joojaa Sep 1 '15 at 17:26
  • 1
    No because each file could have a different amount of clipping mask. I am finding that selecting everything and release clipping mask is not releasing all the clipping masks at once. There are layers of clipping masks. – buzlink Sep 1 '15 at 18:52
8

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");
  • But does that take care of Groups and Compound paths? – MicroMachine Jul 17 '17 at 17:09
  • Yes, it take care of groups and compound paths, see last 4 rows of my answer. – emax Jul 18 '17 at 11:24
3

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: https://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;

3

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.

1

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.

https://forums.adobe.com/thread/287643

  • But then micro machine is describing exactly the usecase where an action called 10 times would do the job. – joojaa Jul 13 '17 at 21:19
  • I don't understand. By performing 1 action (initiating the script) all clips can be released. Another 2 scripts might need to be created to Ungroup and Release Compound Path, or this 1 script can be modified to handle all three actions on the file, no matter how many clips, groups or masks, through iteration. – Webster Jul 13 '17 at 21:25
  • 1
    One action can do all of those things in one go even without a script. There is no downside to calling ungroup a extra amount of times. But a script can not be bound to a persistent hotkey, because once ai is relaunched the link to script is gone. Actions can. – joojaa Jul 14 '17 at 8:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.