The ‘H’ operator sets a visibility flag for objects internally in blender, and isn’t accessible by the python API. I asked about this a few weeks ago on devtalk.
It’s possible to test the following by properties alone:
- If an object is hidden using only ‘H’ (or the eye icon in outliner)
- If an object is hidden with (at least) the monitor icon:
It’s not (yet) possible to distinguish if an object is hidden only with the monitor icon by property. However, you can toggle
hide_viewport and re-test the object to determine if the
True, and if so you’ll know that it was hidden using only the monitor icon. Performance wise it shouldn’t have an impact since the scene isn’t redrawn until after the script, or if something in the script calls a redraw.
A quick example:
# prints the name of hidden objects
context = bpy.context
with_eye = 
with_monitor = 
with_eye_and_monitor = 
for o in context.view_layer.objects:
if not o.hide_viewport and not o.visible_get():
o.hide_viewport = False # toggle to test visibility
o.hide_viewport = True # toggle back
"With eye only:\n",
[o.name for o in with_eye])
"With monitor only:\n",
[o.name for o in with_monitor])
"With eye and monitor:\n",
[o.name for o in with_eye_and_monitor])
As for hiding objects again with the appropriate setting;
Objects hidden with only
hide_viewport only needs that property changed back.
Objects hidden with
bpy.ops.object.hide_view_set(), however probably requires context override or selection by script, until the property this operator toggles is exposed.