[ REQUEST ] Can "layer.allLocked" be accessed without selecting it?

I’ve seen that I only can change the layer “allLocked” if the layer is selected.

With JSX this was totally possible without selectin the layer, only having layer layer stored in a variable was able to change this “allLocked” property.

But I found with UXP you need to select the layer first to make the layer allLocked true / false.

Is it possible to change this property without the need to select the layer?

Why I request this? Speed, optimization for faster plugins.

The next code doesn’t work if the layer is not selected in UXP, however in JSX it was totally possible.

app.activeDocument.layers[0].allLocked= true;

The solution at the moment is to select the layer and then change the allLocked property:

app.activeDocument.layers[0].selected = true;
app.activeDocument.layers[0].allLocked = true;


IIRC it’s not just visibility. There are more things you can’t do if layer is not selected. I use batch play to change layer related stuff:

  • Save all selected layers list to a variable
  • Add BP actions for each of these layers:
    • Select single layer
    • Change what you need with this layer
  • Re-select all the layers from the saved list

It’s a single Batch Play for all layers and works pretty fast

1 Like

Yeah I think I would need to use batchPlay for this instead DOM. I really love BP it is like 500% faster than AM, I was very curious if this was going to be implemented in the DOM.

Do you know if batchPlay is faster than DOM? Or the DOM is actually a framework/ bunch of functions that uses batchPlay behind the scenes?

Also locking and unlocking layers doesn’t work as well if the layer is not selected.

The following seems to work fine with me in a 3 layers setup where the topmost (i.e., not the one with index 1) is selected:

await executeAsModal(() => {
    doc.layers[1].visible = false;
}, { commandName: "hide layer #1, which is not selected" })

Are you sure you’re using api v2? You should definitely migrate to them if you want to make use of the newest DOM API (I’m on v2 but I haven’t tried v1).

Do you know if batchPlay is faster than DOM? Or the DOM is actually a framework/ bunch of functions that uses batchPlay behind the scenes?

As somebody who’s implemented the DOM, I can assure you that it’s more than a bunch of BP functions. BP is probably gonna be faster, but the DOM (in the words of a PS engineer) “prevents you from shooting yourself in the foot”. :grin:


I just made a huge mistake here and I apologize for it. I wanted to ask about the doc.layers[0].allLocked property and not the “visibility”, my bad… lol

Visibility works as expected, but allLocked is the one that needs the layer to be selected in order to be changed.


I already edited the title of the post.

Also, thanks for clarifying about the DOM and batchPlay! I feel very comfortable with batchPlay as I’m kind of very familiarized with JSON and Action Manager.