Skip to content

Instantly share code, notes, and snippets.

@lm913
Created December 23, 2015 15:26
Show Gist options
  • Save lm913/1a98fa6157b3a724c014 to your computer and use it in GitHub Desktop.
Save lm913/1a98fa6157b3a724c014 to your computer and use it in GitHub Desktop.
Creates a New Mask within a pre-processing script
function psNewMask(showHide,appliedLayer){
//"HdAl" - Hides; "RvlA" - Reveal All; "RvlS" - Reveal Selection
try{
app.activeDocument.activeLayer = doc.artLayers.getByName(appliedLayer); //variable must be string
}
catch(e){
}
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var descMask = new ActionDescriptor();
descMask.putClass(cTID("Nw "), cTID("Chnl"));
var refMask = new ActionReference();
refMask.putEnumerated(cTID("Chnl"), cTID("Chnl"), cTID("Msk "));
descMask.putReference(cTID("At "), refMask);
descMask.putEnumerated(cTID("Usng"), cTID("UsrM"), cTID(showHide));
executeAction(cTID("Mk "), descMask, DialogModes.NO);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment