1
$\begingroup$

I'm trying to create a Panel to control showing and hiding a set of objects and their children. Creating a toggle to update an item's visibility is no problem, but I can't figure out how to avoid updating its children unless the toggle was pressed this draw:

class ShowItemsPanel(bpy.types.Panel):

def draw(self, context):

    # get all children of item container 
    for item in bpy.data.objects['Items'].children: 

        # set hide property 
        self.layout.prop(item, 'hide', toggle=True, text=item.name)

        # childrens' hide properties are updated every draw; how to avoid this? 
        for child in item.children: 
            child.hide = item.hide 

I considered creating a set of dummy BoolProperties with an update function as shown here, but I can't figure out how to apply this approach to my use case since the number of items is variable.

Can anyone point me to the best way to handle this type of case?

$\endgroup$
  • $\begingroup$ You cannot set properties like ob.hide from the draw method of a panel class. Related $\endgroup$ – batFINGER Aug 17 '18 at 4:48

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.