Photoshop Script: Layer Visibility
Hello guys,
I want to create a script that toggles specific layers visibility (multiple layers) based on a single layer visibility, so if i make "Star" layer visible from the group called "VersusVV1" from the artboard called "Versus Images", than will toggle in the same group in same artboard some layers, but else if that layer is visible, will toggle them back to invisible.
I found a base code but this is only for layers, but i have more artboards in this PSD and i have 3 duplicated groups with same layer names so i will need to specific from what group to select the layers, as well i have a Left and a Right group, in both groups i have same named layers that needs to be checked, the idea is that i can select what artboard, what group, what other group and what layer to be checked in those groups that will toggle the specific layers, this could make my work easier because i need to modify the PDF frequently and i have too many layers to toggle on and off so to toggle only one layer and the others to toggle after it, would be amazing...
This is the base code i found, i haven't tested, i use latest photoshop version from Creative Cloud.
So i need like this:
for ArtBoard = "Versus Images"{
for Group = "VersusVV1"{
for Group = "Left"{
if app.documents.layers.item("Stars").visible == true{
app.documents.layers.item("Stars Logo").visible = true;
app.documents.layers.item("Stars Shade").visible = true;
app.documents.layers.item("Stars BG").visible = true;
app.documents.layers.item("Stars Color").visible = true;
}
}
}
}
Base code from what i've got inspired:
var docs = app.documents;
for (var i = docs.length-1; i >= 0; i--) {
if(docs[i].layers.item("Chi").visible == true && docs[i].layers.item("Chi").locked == false)
{
docs[i].layers.item("Chi").visible = false;
docs[i].layers.item("Chi").locked = true;
docs[i].layers.item("Eng").visible = true;
docs[i].layers.item("Eng").locked = false;
}
else if(docs[i].layers.item("Eng").visible == true && docs[i].layers.item("Eng").locked == false)
{
docs[i].layers.item("Chi").visible = true;
docs[i].layers.item("Chi").locked = false;
docs[i].layers.item("Eng").visible = false;
docs[i].layers.item("Eng").locked = true;
}
}
alert("Done.")
I would be happy if someone could help me out, i am really new to scripting in photoshop but this could help me understand how this works, i need scripts for a lot of my PSD's with this issue so i could make scripts for every one of it that could help me a ton
Thank you in advance! Zayon
