How to check if a collection is selected or not in the outliner using Python?

enter image description here

Here I've selected the following collections: "scene 1", "scene 2" and "scene 3".

  • $\begingroup$ very good question! there's no direct blender python api for that i guess. you can only know what the currently selected collection name is with bpy.context.collection.name $\endgroup$ Jan 15, 2023 at 9:49

1 Answer 1


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:


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:

You must log in to answer this question.

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