Active collection

To get the current active collection through the Blender Python API we need to access it through the "view_layer" layer.



[b3di_buy_on patreon="55401206" patreon_txt="Content on Patreon"]

The following command will return the active collection from the scene:



bpy.context.view_layer.active_layer_collection.collection

# <bpy_struct, Collection("Collection 2") at 0x000001F872BE3608>

The active collection can also be accessed directly through the current context:



bpy.context.collection

# <bpy_struct, Collection("Collection 2") at 0x000001F872BE3608>

Note that toggling the collection visibility in the outliner using the "eye" and "monitor" icons resets the currently active collection and makes the scene's main collection active.





*.blend file with the example code for my Patreon subscribers

Комментарии

Популярные сообщения