3
$\begingroup$

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.

$\endgroup$
4
$\begingroup$

Delete all groups in blend file.

BlendDataGroups.remove(...)

import bpy

for g in bpy.data.groups:
    bpy.data.groups.remove(g)

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:
    bpy.data.groups.remove(empty_groups.pop())

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(
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

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.