Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Toggle Visibility of All Layers in a Group

Community Beginner ,
Sep 10, 2018 Sep 10, 2018

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

TOPICS
Actions and scripting
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Sep 12, 2018 Sep 12, 2018

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");

    }

Translate
Adobe
LEGEND ,
Sep 10, 2018 Sep 10, 2018

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 10, 2018 Sep 10, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 10, 2018 Sep 10, 2018

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");

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 12, 2018 Sep 12, 2018

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 12, 2018 Sep 12, 2018

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");

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 12, 2018 Sep 12, 2018
LATEST

Awesome, thanks!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines