Answered
Is it possible to make a layer mask with the current selection using extendscript?
I've had no luck and was wondering is someone knows how. Thanks.
I've had no luck and was wondering is someone knows how. Thanks.
Yes, but not with DOM code, you need AM code. I'll post the code shortly...
To add a reveal or hide mask from an active selection:
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 );
}
https://gist.github.com/MarshySwamp/cbd0f135aa6ad089b053c80a2a02edaa
To add a "full" layer mask with no selection:
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);
}
https://gist.github.com/MarshySwamp/5eb4863d08335e870a53ef04ccb33916
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.