Test whether the document is in an "isolate layer" state


I have the action for isolating a layer (option+clicking the eyeball so it’s the only visible layer), which is:

  "_obj": "show",
  "null": [{
      "_ref": "layer",
      "_enum": "ordinal",
      "_value": "targetEnum"

However, how do I test whether the document is already in an isolate state before toggling it?
would I have to count the layers manually, like…

const app = require('photoshop').app;
let layerVisible = 0;
app.activeDocument.layers.forEach((layer) => layerVisible += layer.visible);
// or something??

The issue is that simply having one visible layer does not constitute photoshop recognizing the document as being in an isolated visibility state. For now, I’m just going to count the layers and toggle an isolate state if more than one layer is detected.

I just don’t know if there’s a better way I can check for this.

1 Like

In my Mask Checker plugin I rather created my own Isolation method that even allows isolating multiple layers at once. And I store that state in document metadata. But it is not supposed to work together with build-in isolation mode :smiley: :expressionless: https://www.mightyplugins.cc/mask-checker

So you could possibly re-create that feature and then you are in control because I think you can’t currently reliable read that state… but I would like to be wrong :smiley:

1 Like