hidden ob ?

how do you find hidden ob in scene ?

bpy.context.scene.objects

seems to gather only visible ob !

happy bl

bpy.context.scene.objects contains all objects in the scene, no matter if they are hidden, on another (currently not visible) layer or another object in local view mode.

You can get just the “hidden” ones e.g. like

[ob for ob in bpy.context.scene.objects if ob.hide]

But it won’t return objects on a non-visible layer. If you want all objects having the hide property set to True as well as objects on non-visible layers, you could apply some set theory:

set(bpy.context.scene.objects) - set(bpy.context.visible_objects)

Alternatively, this would also work:

scene = bpy.context.scene
[ob for ob in scene.objects if ob.hide or not all(map(lambda x: x[0] is x[1], zip(scene.layers, ob.layers)))]

did a quick test with



print()
print (' len ob  = ' ,len(bpy.context.scene.objects ))
	
print()
	
j1 = 0
j1hide = 0

for ob in bpy.context.scene.objects :
	
	if ob.hide:
		print ('            hidden = ' ,ob.name)
		j1hide+=1
	else:
		print ('name = ' ,ob.name)
		j1+=1
	
print()
	
print (' OB = ' ,j1, ' ob hidden =', j1hide )
print()
	




the len of scene ob gives only visible ob !
all hidden ob or ob on off layers are not calculated !

is there a command that gives the different count ?

how do you find obs on other scenes ?

thanks
happy bl

the len of scene ob gives only visible ob !

No it does not. Scene.objects is not even a direct context member, it’s a plan list of all objects linked to the scene. Alternatively, you could use the object bases.

how do you find obs on other scenes ?

By not using bpy.context.scene but bpy.data.scenes[…]