In the outliner i have a local library called "Current File" and a linked library called "//foo.blend". Is this the proper way to remove all unused group-datablock-links from the "//foo.blend"-library?

import bpy

groups = bpy.data.groups
for group in groups:
    if group.library and group.library.filepath == "//foo.blend":
        if group.users == 1 and len(group.users_dupli_group) == 0: # EDIT
            groups.remove(group)  # <- crash warning, don't use this part of the example.
  • $\begingroup$ Using user_clear() can be dangerous, you should always try to get user count to 0 by clearing references that exist, see user_clear() $\endgroup$
    – CodeManX
    Oct 4, 2013 at 17:32
  • $\begingroup$ @CoDEmanX, user_clear() is safe, but user_clear() followed by remove() can crash if the group was used anywhere. Best use user_clear() then save and reload. $\endgroup$
    – ideasman42
    Oct 5, 2013 at 3:41
  • $\begingroup$ but with len(group.users_dupli_group) == 0 added, it should be save? $\endgroup$ Oct 5, 2013 at 9:56
  • $\begingroup$ @ni-ko-o-kin, no, because there are group users that are not dupli-groups (particle-systems for example). $\endgroup$
    – ideasman42
    Oct 6, 2013 at 5:48

2 Answers 2


Groups are intentionally not garbage collected, (so they have to be removed manually). Only a few kinds of data-blocks behave this way, Scene's are another example.

As a user, you can select them in the outliner and unlink them, but there is no way to remove single user groups other then to script this as you have done.

For details see the reference manual.


Add an object, just something simple like a cube, add that cube to the group you want to remove. Hit Ctrl + Alt + G, and choose the group you want to remove. Then close the scene, and re-open it. That group will be gone!

  • $\begingroup$ I don't think it's necessary to add a cube. $\endgroup$
    – gladys
    Aug 2, 2015 at 9:00

You must log in to answer this question.

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