How to get selection objects list in outliner?

I’m making simple script which can toggle hide or unhide.
But I can’t get selection objects lists in outliner.

Getting object selection list which selected in viewport is easy.
(using bpy.context.selected_objects)

I can select hide objects in outliner only.
But,Getting object selection list which selected in outliner is difficult.

I can get last selected object in outliner, (using bpy.context.selected_objects)
But I can’t get all selected objects list in outliner.

Please help me.
q01

I’m in the same situation, if someone has some knowledge to share I/we would be delighted.

Here’s my questions on Stack exchange: https://blender.stackexchange.com/questions/160694/how-to-toggle-selected-objects-visibility-with-h-shortcut-as-in-maya

In 2.7 this was easily accessible through so-called object bases, which there no longer are no entry points to from python afaik. However, one way to determine the objects is by temporarily unhiding things and cross reference the selections.

Made a quick addon out of it. The hotkey is set to J to avoid colliding with the vanilla operator, but can easily be changed.

1 Like

I tried to install the .py file in 2.81 but it doesn’t seem to show up in the addon list, it’s added to the addon folder (…2.81\scripts\addons) though and pressing J doesn’t work of course. Any ideas how to make it install and work?

Sounds like you downloaded the web page instead. Visit the link, right-click “Raw”, then save link as file.

Ah thanks, that was it, took a look in the installed .py file in indeed it was an html file and…

Wow thank you so much for the script, it’s working great.

1 Like

Hello,
I was looking for a similar solution
but doesn’t seem to work in 2.83+
it switches once and then hides everything and stops working …
@iceythe can you look at code to make it work in 2.83+ or in 2.9. Thanks!