In my plugin I have an operator that needs to iterate through potentially 100's of objects that might be 'hidden in viewport' or 'disabled in viewport' and perform some operations that require the object to be visible in viewport. Afterwards I want to restore whatever visibility the object had, so I need to both get and set these options.

Two icons IE, get/set the status of these.

When I hover over the icons, both show the parameter bpy.context.object.hide_viewport. Obviously they can't both be the same parameter as they both do different things. How do I get and set 'hidden in viewport' and how do I get and set 'disabled in viewport' using the Python API?

Edit: I can see that both ObjectBase(bpy_struct) and Object(ID) have the hide_viewport property, however ObjectBase is documented as 'Temporarily hide in viewport' and Object is documented as 'Globally disable in viewports'. How do I access an Object's ObjectBase?


2 Answers 2


To iterate on the other answer which left out the get parts:

Note hide_get takes an optional bpy.types.ViewLayer argument if you want to get the visibility status of an object in a view layer that's not currently active.

Also note obj.hide_viewport invalidates any iteration upon a collection's all_objects. See https://docs.blender.org/api/current/info_gotcha.html#collection-objects


bpy.context.active_object.hide_viewport = True for MONITOR icon bpy.context.active_object.hide_set(True) for EYE icon

for collections it's bit different bpy.context.collection.hide_viewport = True will globally hide collection(MONITOR icon) bpy.context.view_layer.layer_collection.children.get('Your_Collection_Name').hide_viewport = True wil hide collectiob locally (EYE icon)

  • $\begingroup$ Calling hide_set(True) will still leave the object grayed out in the Outliner. Why? $\endgroup$ Apr 23, 2021 at 15:17
  • $\begingroup$ @AndreasHaferburg Does object shows in viewport but grayed out in outliner? If you move your cursor in outliner then object should not be grayed out. This happens because blender does not draw particular area unless there are activity in that. You can redraw in code using area.tag_redraw() $\endgroup$
    – Reigen
    Apr 24, 2021 at 15:39
  • $\begingroup$ I hide the object by clicking the eye icon in the outliner. Then I unhide using hide_set(False). It becomes visible in the viewport, but it stays grayed out in the Outliner, even after clicking on another object in the Outliner. $\endgroup$ Apr 25, 2021 at 8:24

You must log in to answer this question.

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