1
$\begingroup$

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

Thanks.

$\endgroup$
8
  • $\begingroup$ Efficient in which context? What you'd like to do? $\endgroup$
    – brockmann
    Commented Jul 9, 2019 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
    Commented Jul 9, 2019 at 21:04
  • $\begingroup$ Selected objects or random objects in the scene? $\endgroup$
    – brockmann
    Commented Jul 9, 2019 at 21:11
  • $\begingroup$ I have 12 objects which I turn on/off constantly. $\endgroup$
    – L. Phan
    Commented Jul 9, 2019 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
    Commented Jul 9, 2019 at 21:42

0

You must log in to answer this question.

Browse other questions tagged .