Skip to content

Instantly share code, notes, and snippets.

@MarshySwamp
Created January 6, 2022 00:58
Show Gist options
  • Save MarshySwamp/cbd0f135aa6ad089b053c80a2a02edaa to your computer and use it in GitHub Desktop.
Save MarshySwamp/cbd0f135aa6ad089b053c80a2a02edaa to your computer and use it in GitHub Desktop.
Add a "reveal" or "hide" selection based layer mask
maskSelection("revealSelection");
function maskSelection(maskParameter) {
// Parameter = "revealSelection" or "hideSelection"
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
descriptor.putClass( s2t( "new" ), s2t( "channel" ));
reference.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( "mask" ));
descriptor.putReference( s2t( "at" ), reference );
descriptor.putEnumerated( s2t( "using" ), s2t( "userMaskEnabled" ), s2t( maskParameter ));
executeAction( s2t( "make" ), descriptor, DialogModes.NO );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment