"Hide in Viewport" for collections in python API?

How do I see (and set) the status of the eye in the outliner (hide in viewport) for collections using the python API?

It’s here:
https://docs.blender.org/api/master/bpy.types.Object.html?highlight=hide_get#bpy.types.Object.hide_get

1 Like

This is for Objects, not for Collections.
You can hide collections per view layer inthe outliner, but not via python,
I’ve also mentioned it here, along with show_expanded

To globally hide a collection

bpy.data.collections['My Collection'].hide_viewport = True

To hide collections based on view layer

vlayer = bpy.context.scene.view_layers['My View Layer']
vlayer.layer_collection.children['My Collection'].hide_viewport = True
8 Likes

Thanks, that works! Still hoping for a hide_set() to come along at some point for convenience.

1 Like