Is there a way to automatically delete children when the parent is deleted? By automatically I mean that you don't do any selection (or other action) of the children prior to selecting and deleting the parent.
I can make a method that select and delete the children. But I'm not sure how to call this prior to the bpy.ops.object.delete() operator. Maybe some custom property of the objects with some clever update? Or maybe a handle?
EDIT: I tried to override the delete operator like this:
class MYOP_OT_delete_family(bpy.types.Operator):
bl_idname = "object.delete"
bl_label = "Delete parent, children and sibling"
bl_options = {'REGISTER', 'UNDO'} # Must have REGISTER!
def execute(self, context):
top_object = context.object
if top_object.parent is not None:
top_object = top_object.parent
top_object.select_set(True)
for child in top_object.children:
child.select_set(True)
bpy.ops.object.delete() # BUT THIS IS NOW OVERRIDDEN!!!
return {'FINISHED'}
This breaks Blender when I delete something. This is not surprising, since I both rely on and override the bpy.ops.delete operator. I suppose that I can make this as a new operator (bpy.ops.delete_family as the class name) and then keymap to this operator. But I would prefer not to have to do these manual setup things and truely override the default delete operator.