2
$\begingroup$

I can find only active collection with bpy.context.collection, there should be bpy.context.selected_collections similar to bpy.context.selected_objects.

How to get a list of selected collections?

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Does this answer your question? Python : Get selected objects in outliner $\endgroup$
    – Gorgious
    Commented May 18, 2023 at 19:43
  • $\begingroup$ And how is bpy.context.selected_ids different from bpy.context.selected_objects ? $\endgroup$
    – Gorgious
    Commented May 19, 2023 at 5:48

1 Answer 1

1
$\begingroup$

This answer is based on https://blender.stackexchange.com/a/293231/123423

import bpy
from bpy import context


def selected_collections(context):
    for area in context.screen.areas:
        if area.type == 'OUTLINER':
            with context.temp_override(area=area):
                return [item for item in context.selected_ids if isinstance(item, bpy.types.Collection)]


print(selected_collections(context))
$\endgroup$

You must log in to answer this question.

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