BEFORE_AFTER_Show_Hide not worke true in photoshop

Hello, everyone .
I want to help find a solution to make the following code.

`const BEFORE_AFTER_Show_Hide = async () => {
  let wantedLayer = "BEFORE_AFTER"
  const layers = await require("photoshop").app.activeDocument.layers;
    for (layer of layers) {
        if ( == wantedLayer) {
   = !
    console.log("BEFORE_AFTER_Show_Hide Result!!!")

The code in the console works fine, when the button is pressed.

But in Photoshop it does not respond to the command.

My Photoshop version:24.2.0
What I want the code to do is show and hide the name of the selected layer within the code only when the button is pressed.
With regards…
Mohamed Fathi…

  1. Your posted screenshots doesn’t actually prove anything, because in one the code itself is missing and in the other it’s just a layer list without any buttons
  2. What is Where did you find such property?


I don’t think there is any way that you can hide the layer name. There is definitely no method.
I guess you could rename the layer with an empty string, I’ve never tried so I don’t know if PS accepts a layer with no name.

to fix your code change this: = !

to this

layer.visible = !layer.visible

however here’s a shorter way without using loop:

const app = require("photoshop").app
const BEFORE_AFTER_Show_Hide = async () => {
    const layers = app.activeDocument.layers;
    let wantedLayer = layers.getByName("BEFORE_AFTER");
    wantedLayer.visible = !wantedLayer.visible;

I’m guessing he wants to hide the layer itself using its name.

Yeah … Yeah … Yeah.
Thank you, Maher, yes, that’s exactly who I am you’re a super hero. :man_lifting_weights: :wine_glass:

Ah, I assumed it was just hiding the name based on @Mohamad already having solved hiding a layer by name yesterday. :rofl:

Thanks for your reply, Timothy.
Yesterday I wanted to hide the layer inside a group, but in my case today I wanted to hide the layer outside the group, it was in the work file as a whole.
As my friend, I’m basically not a programmer, it’s just a hobby I have , I’m trying to develop it, and I know this only comes over time, learning and delving into the programming sea.I respect your work as a programmer, but I’m a hobby, I have my own plugin, which is in CEP format, and now I’m converting to uxp format.
I work my main job as a chartered accountant at Ford Motor Company, and I have two master’s degrees in accounting (Cost Accounting + Management Accounting).
With regards…
Mohamed Fathi… :wine_glass:

Oh, I meant no offence! I was just pointing out why I’d assumed you meant to hide the layer name and not the layer.
I know only too well the struggle of self-instruction :joy:

1 Like

I know my friend
I always like to meet new friends
I was pleased to meet you all on this forum.
And I respect all of you and I hope to be a friend to all of you :wine_glass:

1 Like