Copy link to clipboard
Copied
Hello Everyone,
Currently, I am using the script to hide the Layer "TB" and lock all layers in the active document:
var document = app.activeDocument;
document.activeLayer = document.layers["TB"]
document.activeLayer.visible = false;
var lc = document.layers.length;
for (var i=1; i<=lc; i++) {
document.layers[i-1].locked = true;
}
But in some cases, my document doesnot have the "TB " layer, in that case i need to skip this step and need to run further.
Please give your inputs to overcome this.
Hi,
You can use, try and catch.
var document = app.activeDocument;
try {
document.activeLayer = document.layers["TB"];
document.activeLayer.visible = false;
} catch (e) {
}
var lc = document.layers.length;
for (var i = 1; i <= lc; i++) {
document.layers[i - 1].locked = true;
}
Copy link to clipboard
Copied
Hi,
You can use, try and catch.
var document = app.activeDocument;
try {
document.activeLayer = document.layers["TB"];
document.activeLayer.visible = false;
} catch (e) {
}
var lc = document.layers.length;
for (var i = 1; i <= lc; i++) {
document.layers[i - 1].locked = true;
}
Copy link to clipboard
Copied
Thank you so much @Charu Rajput