I can get selected Collection with
but how to get list of multiple selected collections?
As of 2.92, the outliner exposes all selected data-blocks via context:
Collections are data-blocks/IDs (the scene collection being an exception!) so this should work.
This was added for the asset browser and will probably be extended for more specific queries and used much more in future (esp. to rewrite the Outliner context menu).
what I tried to do, make modified context menu for collection “Select Objects” to work with multiple collections…thought it was possible untill now.
Thanks for explanation.
import bpy # Set the area to the outliner area = bpy.context.area old_type = area.type area.type = 'OUTLINER' ids = bpy.context.selected_ids print(ids) # Reset the area area.type = old_type
result in console just
 (in 2.93 alpha)
Ok. I just leave it for a while.
(Forgot about this, sorry for the late reply.)
If you create an Outliner from scratch there is no selection, so of course the output will be empty. But if you run it from an area that had an Outliner visible before, and where that Outliner had some selection, it should succeed.
E.g. when I create an Outliner, select something, change that Outliner to a Text Editor and run the script there, I get output like this:
[bpy.data.collections['Collection'], bpy.data.objects['Camera'], bpy.data.objects['Cube']]