Copy link to clipboard
Copied
Greetings all,
Does anyone know if I can check if the view layer mask (the greyscale thumbnail next to the layer) is on or off via scripting?
Thanks in advance!
try this:
#target photoshop
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('hasUserMask'));
r.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
if (executeActionGet(r).getBoolean(p)) {
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('name'));
(r = new ActionReference()).putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
layerName = executeActionGet(r).getString(p);
(r = new ActionReference()).pu
...
Copy link to clipboard
Copied
#target photoshop
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('userMaskEnabled'));
r.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
if (executeActionGet(r).hasKey(p)) alert (executeActionGet(r).getBoolean(p));
Copy link to clipboard
Copied
Copy link to clipboard
Copied
alert(layerMaskHasContent())
function layerMaskHasContent() {
#target photoshop
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('hasUserMask'));
r.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
if (executeActionGet(r).getBoolean(p)) {
(r = new ActionReference()).putEnumerated(s2t("channel"), s2t("channel"), s2t('mask'));
(d = new ActionDescriptor).putReference(s2t("null"), r);
executeAction(s2t("select"), d, DialogModes.NO);
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('histogram'));
r.putEnumerated(s2t("channel"), s2t("ordinal"), s2t("targetEnum"));
var hst = executeActionGet(r).getList(p);
(r = new ActionReference()).putEnumerated(s2t("channel"), s2t("channel"), s2t('RGB'));
(d = new ActionDescriptor).putReference(s2t("null"), r);
executeAction(s2t("select"), d, DialogModes.NO);
for (var i = 0; i < hst.count - 1; i++) { if (hst.getInteger(i)) return true }
return false
}
}
Copy link to clipboard
Copied
Thanks so much, both work as intended.
Sorry I made an error in my image, but I could not change it after posting...
I just mean check if view mask (activated by option click on Mac) is visible (the white/greyscale mask) = true
Normal left view (ie layer mask is not visible) = false
Thanks again
Copy link to clipboard
Copied
try this:
#target photoshop
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('hasUserMask'));
r.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
if (executeActionGet(r).getBoolean(p)) {
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('name'));
(r = new ActionReference()).putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
layerName = executeActionGet(r).getString(p);
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('channelName'));
r.putEnumerated(s2t("channel"), s2t("ordinal"), s2t("targetEnum"));
channelName = executeActionGet(r).getString(p);
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('alphaChannelOptions'));
r.putEnumerated(s2t("channel"), s2t("ordinal"), s2t("targetEnum"));
alphaChannel = executeActionGet(r).hasKey(p);
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('visible'));
r.putEnumerated(s2t("channel"), s2t("ordinal"), s2t("targetEnum"));
channelVisible = executeActionGet(r).getBoolean(p);
alert (channelName.indexOf(layerName) == 0 && !alphaChannel && channelVisible)
}
Copy link to clipboard
Copied
Fantastic!
Thank you very much jazz-y : )