How to check if a collection is selected or not in the outliner using Python?
Here I've selected the following collections: "scene 1", "scene 2" and "scene 3".
How to check if a collection is selected or not in the outliner using Python?
Here I've selected the following collections: "scene 1", "scene 2" and "scene 3".
As far as I know, there is no direct way to check if certain collections are selected. You can only check what the name of the currently selected collection is using:
bpy.context.collection.name
and you can check what the actively selected collection is:
import bpy
for collection in bpy.data.collections:
if collection == bpy.context.view_layer.active_layer_collection.collection:
print(collection.name)
bpy.context.collection.name– Harry McKenzie Jan 15 '23 at 09:49