Here are a few objects that I have hidden:
I am using the script below to make them visible:
bpy.ops.object.hide_view_clear()
but it does not help.
So what is the perfect script to make them visible?
Here are a few objects that I have hidden:
I am using the script below to make them visible:
bpy.ops.object.hide_view_clear()
but it does not help.
So what is the perfect script to make them visible?
As of Blender 2.81, Object.hide_set() is working properly and seems to be the equivalent of Object.hide property in 2.7x versions.
Proof using the console:
>>> bpy.context.object.hide_set(False)
To unhide multiple objects you can run over objects in the scene and call the setter per object:
for o in ("Cube", "Camera", "Light"):
obj = bpy.context.scene.objects.get(o)
#if obj: obj.hide_viewport = False
if obj: obj.hide_set(False)
You can also iterate through any given collection:
col = bpy.data.collections.get("Collection")
if col:
for obj in col.objects:
obj.hide_set(False)
Whatever you like...
You need a way to specify which objects to unhide. Hidden objects cannot be selected, so you cannot just use bpy.context.selected_objects, you can use their names to identify them or whatever other attribute. You will need to loop through the objects from which you wish to pick the ones to unhide, you could use bpy.data.objects to do that for all scenes, but bpy.context.scene.objects are all the objects in the current scene that you are more likely to wish to work with. The script picking them by name could be something like this:
import bpy
for o in bpy.context.scene.objects:
if 'Cube' in o.name:
o.hide_viewport = o.hide_render = False
Note that there are a few ways to hide objects. object.hide_viewport or object.hide_render or object.hide_select
You can find out stuff like that using autocomplete functionality of the Python console (ctrl+space while hovering mouse over Python console panel with some text you started typing):
C is short for bpy.context in the console. C.object is the active object.
Shift+Mouse_Clickfor hiding an object with its children. Now I am iterating over the children objects andhide_set(True)them individually. My guess is that under the hood is the same procedure that is happening but I was wondering if someone can just call the build in functon instead of re-implementing it. – ttsesm Oct 08 '20 at 12:21Shift+LMBis reserved for multi-selection in the outliner. I recommend ask a new detailed question referring to this one @ttsesm – brockmann Oct 08 '20 at 12:49