Skip to content

Instantly share code, notes, and snippets.

@MarshySwamp
Last active January 10, 2022 03:30
Show Gist options
  • Save MarshySwamp/5eb4863d08335e870a53ef04ccb33916 to your computer and use it in GitHub Desktop.
Save MarshySwamp/5eb4863d08335e870a53ef04ccb33916 to your computer and use it in GitHub Desktop.
Add a "reveal all" or "hide all" layer mask
addMask("reveallAll");
function addMask(maskVisibility) {
// maskVisibility = "revealAll" or "hideAll"
var c2t = function (s) {
return app.charIDToTypeID(s);
};
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"), c2t("UsrM"), s2t(maskVisibility));
executeAction(s2t("make"), descriptor, DialogModes.NO);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment