Copy link to clipboard
Copied
So, I admit, I'm tired of searching for a script to do this, and I'm shocked I haven't found one yet.
Is there a script that will toggle the visibility of all layers in a group?
Any reply is greatly appreciated
-Andy
var set;
if (activeDocument.activeLayer.typename == "LayerSet") set = activeDocument.activeLayer
else set = activeDocument.activeLayer.parent;
if (set.typename == "LayerSet")
{
set.layers[0].visible = !set.layers[0].visible;
for (var i = 1; i < set.layers.length; i++)
set.layers.visible = set.layers[0].visible;
}
else
{
alert("LayerSet or Layer in LayerSet must be selected");
}
Copy link to clipboard
Copied
Rewrite the script that is doing something else but between other things does that you want:Export combination of layers
Here you have easier code to modify and then to use the way you wish: Re: Modify script to select hidden layers/groups?
Copy link to clipboard
Copied
Ok thanks Kukurykus. I'm not a scripter myself in the least, but I will look at the code and see what I can do.
Copy link to clipboard
Copied
Try this
var set;
if (activeDocument.activeLayer.typename == "LayerSet") set = activeDocument.activeLayer
else set = activeDocument.activeLayer.parent;
if (set.typename == "LayerSet")
{
for (var i = 0; i < set.layers.length; i++)
set.layers.visible = !set.layers.visible;
}
else
{
alert("LayerSet or Layer in LayerSet must be selected");
}
Copy link to clipboard
Copied
Hi r-bin,
Thanks so much! Sorry for just now replying to your post. I've been busy. But I do very much appreciate it. Now just one more thing.. would it be an easy tweak to toggle the visibility of all the layers in the selected group whether some are already visible and some are not? (if that makes sense)
Thanks in advance!
Copy link to clipboard
Copied
var set;
if (activeDocument.activeLayer.typename == "LayerSet") set = activeDocument.activeLayer
else set = activeDocument.activeLayer.parent;
if (set.typename == "LayerSet")
{
set.layers[0].visible = !set.layers[0].visible;
for (var i = 1; i < set.layers.length; i++)
set.layers.visible = set.layers[0].visible;
}
else
{
alert("LayerSet or Layer in LayerSet must be selected");
}
Copy link to clipboard
Copied
Awesome, thanks!!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now