Enabling and disabling collections using the Blender Python API

We can enable and disable a collection from interaction with the scene by switching the checkbox located in the Outliner opposite the name of the desired collection. In order to do this using the Blender Python API, we need to access the collection through the View Layer of the scene on which the desired collection is located.

The “exclude” property is responsible for turning a collection on and off. However, the scene collection (bpy.context.collection) does not have this property.

This property can be accessed through the View Layer collection.

The currently active collection on the currently active View Layer:

Disabling the collection (off the checkbox):

And enabling the collection back (on the checkbox):

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Inline Feedbacks
View all comments