1
$\begingroup$

I've had a good look online but can't seem to find an answer to making sub collections visible. I've attached an image that shows the main collection called Block Garage which is ticked and then within it there are other sub collections (windows.001, Drainage.002). While I can tick the make visible box, I would have expected it to make everything else inside that collection visible also but this is not the case. Instead I have to go down the list and manually tick all the other boxes.

Is there any shortcut to do this as I have many more collections of other building that I want to hide or show depending on which one I'm currently working on?

Please note that I don't want to unhide all the objects in the blender file, I just want to unhide all the subfolders and objects within a specific collection.

enter image description here

$\endgroup$
6
  • $\begingroup$ Also it might not help you much, but you can click on the most upper symbol, hold down your mouse key and then drag down to enable multiple items. So you don't have to manually click + move cursor a lot of time. If you really wanna help for that, you could write a python script for this (or maybe there is already an add-on) - shouldn't be too much work to realize it. $\endgroup$
    – Chris
    Commented May 10 at 6:18
  • 2
    $\begingroup$ Do you try Shift+LMB when clicking on the "eye" of a (sub-)collection ? $\endgroup$ Commented May 10 at 6:55
  • $\begingroup$ @StefLAncien wow never thought of that awesome works $\endgroup$
    – Harry McKenzie
    Commented May 10 at 7:24
  • $\begingroup$ Praise should be for someone else because I remember reading this shortcut on BSE, but I could not find the original post. $\endgroup$ Commented May 10 at 7:48
  • $\begingroup$ @StefLAncien i was trying to come up with some python solution where i select the parent collection and iterate through every sub collection and then manipulate the hide_viewport attribute. In the end I was overcomplicating things when we have Shift+LMB hah! $\endgroup$
    – Harry McKenzie
    Commented May 10 at 7:50

1 Answer 1

1
$\begingroup$

As @StefLAncien pointed out, you can toggle the visibility of a collection and all its child collections and objects by shift-left clicking Shift+LMB on the eye icon. For those seeking a Python solution to automate this process, you can utilize the following code. Simply select the collection manually or via python and execute this script to toggle the visibility of the selected collection and its children:

enter image description here

import bpy

def hide_collection_and_all_children(layer_collection, hide=False, depth=0):
    layer_collection.hide_viewport = hide
    collection = layer_collection.collection
    
    for obj in collection.objects:
        obj.hide_set(hide)

    for sub_collection in layer_collection.children:
        hide_collection_and_all_children(sub_collection, hide, depth + 1)

active_collection = bpy.context.view_layer.active_layer_collection

toggle = not active_collection.hide_viewport
hide_collection_and_all_children(active_collection, toggle)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .