Expressions/Scripts/Presets

Moderator: byronnash

 
Navstar
Topic Author
Posts: 68
Joined: Mon Feb 16, 2009 12:41 pm

Mass "Remove Masks" script?

Thu Aug 11, 2016 11:06 am

Since there isn't a keyboard shortcut for Remove Mask, anyone know of a script that can remove all Masks from selected layers?

I've inherited a messy comp with lots duplicated layers that have many unused masks.
 
beginUndoGroup
Posts: 76
Joined: Tue Nov 27, 2012 6:41 am

Re: Mass "Remove Masks" script?

Thu Aug 11, 2016 1:49 pm

You can try this, it removes all masks blindly (save as .jsx in the ScriptUIPanel folder, restart AE, then launch from the Window menu):

this.add("button{text: 'remove all masks'}").onClick = function(){
    var comp = app.project.activeItem;
    if (!comp || comp.typeName !== "Composition" || comp.selectedLayers.length<1){
        alert("No layer selected");
        }
    else{
        var sel = comp.selectedLayers, N=sel.length, n, layer, numMasks;
        var removed = 0;
        app.beginUndoGroup("Remove All Masks");
        for (n=0; n<N; n++){
            layer = sel[n];
            if (!layer.mask) continue;
            numMasks = layer.mask.numProperties;
            removed += numMasks;
            while (numMasks>0) layer.mask(numMasks--).remove();
            };
        app.endUndoGroup();
        alert("Removed " + removed + " masks on " + N + " layers");
        };
    };
this.layout.layout(true);



Xavier
 
zold
Posts: 14
Joined: Fri Mar 25, 2011 9:15 am
Contact:

Re: Mass "Remove Masks" script?

Sat Aug 20, 2016 1:32 am

You can also use my much-neglected "Mask Selection Helper" script on crgreen.com. It allows you to select all or some masks based on index or name matching. After selecting, you have to close the script window, then hit delete and the selected masks (even if they're not revealed) are deleted.

Who is online

Users browsing this forum: No registered users and 2 guests