How to know if a layer has a "clipping mask" in UXP?

With CEP I use to know if a layer is grouped as a clipping mask with this property:


// If it has a clipping mask it returns true and false if not
app.activeDocument.activeLayer.grouped;

However, with UXP the Layer Object doesn’t have this property.

Is there a way to get if a layer has a clipping mask with UXP?

Thanks in advance!

Like this?

async function userMaskOn(execcontext, id) {
   console.log("userMaskOn");
   const result = await batchPlay(
      [
         {
            _obj: "get",
            _target: [
               {
                  _property: "userMaskEnabled"
               },
               {
                  _ref: "layer",
                  _id: id
               },
            ],
            _options: {
               dialogOptions: "dontDisplay"
            }
         }
      ],
      {}
   );
   return result[0].userMaskEnabled;
}
1 Like

https://developer.adobe.com/photoshop/uxp/2022/ps_reference/classes/layer/#properties isClippingMask

1 Like

Not sure what actually OP meant, but I believe it’s a bit different

Whether the layer is being used as a clipping mask

is not the same as

Whether the layer has a clipping mask

1 Like

Yes but he says it worked in ExtendScript and there was only one of them I believe… so it should be correct :smiley:

2 Likes

You are right, I misread. It is late. :wink:

Yes, Jarda is right, you can use app.activeDocument.activeLayers[0].isClippingMask

or via batchplay I think it would be more like the group attribute. (I think)

async function actionCommands() {
   const result = await batchPlay(
      [
         {
            _obj: "get",
            _target: [
               {
                  _ref: "layer",
                  _id: 32
               },
               {
                  _ref: "document",
                  _id: 762
               }
            ],
            _options: {
               dialogOptions: "dontDisplay"
            }
         }
      ],
      {}
   );
   
   const pinned = result[0].group;
}
1 Like

That was easy hahah! Can’t believe I didn’t see this. I went exactly to this page before coming into the forums but when I clicked “properties” on the right, I expected to have the properties on the right as well… So silly of me… Thank you Jarda!

Thank you very much guys for your help !

Yes having that in right menu would help me as well.

1 Like