Skip to main content
Flowgun
Inspiring
August 12, 2025
Answered

How to get the state of Advanced Blending options of a layer?

  • August 12, 2025
  • 1 reply
  • 177 views

Hello,
More specifically, I want to read if "Transparency Shapes Layer" and "Layer Mask Hides Effects" are checked on or off on a layer. I tried various ways to get that info but none of them worked. 

Follow-up question: my goal is to toggle "Transparency Shapes Layer" on if it's off - so I get the bounding box of pixels on the layer - and then off. Is it possible to get the bounding box coordinates of pixels (not of the layer) even with "Transparency Shapes Layer" off? For example, the "Align and Distribute" functions seem to have access to that info regardless of "Transparency Shapes Layer" state and without loading a selection.

Correct answer jazz-y

Read if "Transparency Shapes Layer" and "Layer Mask Hides Effects" are checked on or off on a layer:

s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t("property"), s2t("json"));
r.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
(d = new ActionDescriptor()).putReference(s2t("null"), r);
eval("var json=" + executeAction(s2t("get"), d, DialogModes.NO).getString(s2t("json")));
if (json.layers.length) {
    var cur = json.layers[0],
        blendOptions = { transparencyShapesLayer: true, layerMaskAsGlobalMask: false };
    if (cur.blendOptions) {
        if (cur.blendOptions.transparencyShapesLayer != undefined) blendOptions.transparencyShapesLayer = cur.blendOptions.transparencyShapesLayer
        if (cur.blendOptions.layerMaskAsGlobalMask != undefined) blendOptions.layerMaskAsGlobalMask = cur.blendOptions.layerMaskAsGlobalMask
    }
    alert(blendOptions.toSource())
}

if an option is in the "default" state, it is not shown in the blendOptions object, that is, we need to describe this state in advance and change it only if the option is present

 

Toggle "Transparency Shapes Layer" on/off (and other options):

How to turn visibility on or off for Effects on a layer in JSX? 

 

1 reply

jazz-yCorrect answer
Legend
August 13, 2025

Read if "Transparency Shapes Layer" and "Layer Mask Hides Effects" are checked on or off on a layer:

s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t("property"), s2t("json"));
r.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
(d = new ActionDescriptor()).putReference(s2t("null"), r);
eval("var json=" + executeAction(s2t("get"), d, DialogModes.NO).getString(s2t("json")));
if (json.layers.length) {
    var cur = json.layers[0],
        blendOptions = { transparencyShapesLayer: true, layerMaskAsGlobalMask: false };
    if (cur.blendOptions) {
        if (cur.blendOptions.transparencyShapesLayer != undefined) blendOptions.transparencyShapesLayer = cur.blendOptions.transparencyShapesLayer
        if (cur.blendOptions.layerMaskAsGlobalMask != undefined) blendOptions.layerMaskAsGlobalMask = cur.blendOptions.layerMaskAsGlobalMask
    }
    alert(blendOptions.toSource())
}

if an option is in the "default" state, it is not shown in the blendOptions object, that is, we need to describe this state in advance and change it only if the option is present

 

Toggle "Transparency Shapes Layer" on/off (and other options):

How to turn visibility on or off for Effects on a layer in JSX?