Check visibility state of layer by name X (JS)

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Nightshade

Check visibility state of layer by name X (JS)

Post by Nightshade »

How do I query the visibility state of a particular layer? I don't mind if the layer name is hardcoded so in pseudocode I want something like:
someLayer = "someLayer"
if someLayer.visibleState() == true:
// Do something
else:
// Do something else
xbytor

Check visibility state of layer by name X (JS)

Post by xbytor »

Code: Select allif (doc.activeLayer.visible) {
} else {
}
Nightshade

Check visibility state of layer by name X (JS)

Post by Nightshade »

Yea but that's for the active layer and not a layer of a specific name, right?
Or will this work?:
var someLayer = "myLayer"
if (doc.someLayer.visible){
} else {
}
xbytor

Check visibility state of layer by name X (JS)

Post by xbytor »

Yes, it will work with any Layer or LayerSet object.
PhotoSpot_scripter

Check visibility state of layer by name X (JS)

Post by PhotoSpot_scripter »

if you want to check the visibility of a particular layer by name...

Code: Select allif (app.activeDocument.artLayers.getByName("myLayer".visible) {
} else {
}

PhotoSpot_scripter

Check visibility state of layer by name X (JS)

Post by PhotoSpot_scripter »

Whoops, try this...
Code: Select allif (app.activeDocument.artLayers.getByName("myLayer").visible {
} else {
}
Nightshade

Check visibility state of layer by name X (JS)

Post by Nightshade »

Thanks, Ill check it out.