0
$\begingroup$

In Blender 2.91.2 I'm able to hide objects from the viewport by selecting them first and then using

mySelection = bpy.context.selected_objects
for obj in mySelection:
  obj.hide_set(True)

However, doing the reverse, by selecting them on the outliner doesn't seem as trivial

I'm aware of this post, but still unable to formulate a solution.

I've tried using mySelection = bpy.context.collection but it seems a collection is not iterable.

$\endgroup$

1 Answer 1

1
$\begingroup$
import bpy

bpy.ops.object.select_all(action='DESELECT')

for obj in bpy.data.objects:
    if not obj.visible_get():
        obj.hide_set(False)
        obj.hide_viewport = False
        obj.select_set(True)
$\endgroup$

You must log in to answer this question.

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