Page MenuHome

hide_viewport for object and collection works but UI confused
Closed, ArchivedPublic

Description

System Information
Operating system: Mac OS 12.1
Graphics card: Intel Iris 550 1536 MB

Blender Version
Broken: Version 3.0.0 (3.0.0 2021-12-03)

Short description of error
When using Python's hide_viewport variable to hide an object or a collection, the object or collection is indeed hidden but the UI will not unhide them. The "Hide in Viewport" icon (the little eye) is still "open" but greyed out. Clicking it will close the eye. Clicking again will open it but it, the object and collection remain hidden and greyed out.

Hardly a serious bug but I do avoid using hide_viewport now.

Exact steps for others to reproduce the error
See .blend file. Thanks!

Event Timeline

Alaska (Alaska) closed this task as Archived.EditedJan 17 2022, 8:36 AM
Alaska (Alaska) added a subscriber: Alaska (Alaska).

The "hide_viewport" python code seems to be effecting this setting which is used to globally hide the object:

To be able to view this setting in the outliner, you need to select the Filter button at the top of the outliner and enable it:

This is not a bug, just a mis-understanding of what python code effects which setting. As such I will be archiving this report.

To hide the object via the "eye icon" but through python code you can use something like this:

bpy.data.scenes["Scene"].objects['Cube'].hide_set(True)

Which means for your code you need to change
cube.hide_viewport = True
to
cube.hide_set(True)