Is there a way to delete all groups with the python API? What I want to do is delete all objects and groups in the current environment and then append groups from another file. I've figured out how to delete all the objects but can't figure out how to delete the groups.

Thanks in advance.


1 Answer 1


Delete all groups in blend file.


import bpy

for g in bpy.data.groups:

remove all empty groups (no objects assigned) from blend file

empty_groups = [g for g in bpy.data.groups if not g.objects]
while empty_groups:

Note: For my current version (2.79.4) there are some extra options all set to True by default to "force the issue" without having to unlink and unset users.

>>> bpy.data.groups.remove(
BlendDataGroups.remove(group, do_unlink=True, do_id_user=True, do_ui_user=True)
Remove a group from the current blendfile

See also.

Proper way to remove unused linked Group data-blocks


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .