I was wondering if this is the most efficient way to hide an object using python?

bpy.context.view_layer.objects.active = bpy.data.objects['Cone']; bpy.context.object.hide_viewport = True;

Is there a more efficient way to do this (since I have to turn on/off visibility many times for many objects), maybe something like:

bpy.data.objects['Cube'].visible_set(False); # visible_set doesn't exist unfortunately


  • $\begingroup$ Efficient in which context? What you'd like to do? $\endgroup$ – brockmann Jul 9 '19 at 20:54
  • $\begingroup$ I have to repeat turning objects on and off constantly so I want it to be efficient speed wise. $\endgroup$ – L. Phan Jul 9 '19 at 21:04
  • $\begingroup$ Selected objects or random objects in the scene? $\endgroup$ – brockmann Jul 9 '19 at 21:11
  • $\begingroup$ I have 12 objects which I turn on/off constantly. $\endgroup$ – L. Phan Jul 9 '19 at 21:25
  • $\begingroup$ Just asking because in case the objects are already selected it will be faster than having an extra loop to select geometry beforehand. ALSO: In case you'd like to render your "on/off" animation then you also need hide_render property. Again, if you'd like to have efficient as possible, provide more context. Related: blender.stackexchange.com/a/133470/31447 $\endgroup$ – brockmann Jul 9 '19 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.