Removing "Ghost" Groups and Objects

I’m not sure if this is the right forum, but it seemed the most appropriate.

I have a simple file (camera, lamp, and 3 cubes). When I used the following script …

import bpy
for obj in
    print(">> OBJECT ",

… it lists about 20 objects. The file was created by deleting a bunch of objects from an old file. When I view the the Outliner Editor (All Scenes), I don’t see the objects, but when I change to Outliner Editor (Groups), they’re all shown.

I understand this means I have disconnected (e.g. ghost) data, but my question is “How do I delete them?” I’ve tried selecting and deleting them through the menu, but the delete doesn’t work - they’re persistent little buggers and don’t want to leave.

I’m guessing I can use Python and loop through Groups and remove them all, but I’m still learning Python and the bgy/bge API so I haven’t figured out how to do this. Any suggestions, snippits, or commands that would exterminate these critters would be appreciated? Thanks!


You can try these functions if you like.

def removeObjectFromMemory (passedName):
        ob =[passedName]
        ob = None
    if ob != None:

def removeMeshFromMemory (passedName):
        me =[passedName]
        me = None
    if me != None:

def removeCurveFromMemory (passedName):
        cu =[passedName]
        cu = None
    if cu != None:

Had to use a combo of objects.remove and mesh.remove … but they worked like a charm …

Atom - you’re my new weekly hero … :slight_smile: … Thanks!

You can also just restart blender and they disappear (like magic).

Uncle Entity: save the session and quit blender en start blender and load the last saved one?

Yep, if the object (or any datatype) has zero users it doesn’t get saved in the .blend. In the above example calling user_clear() is a sure-fire way to crash blender.

There are also cases where you can have an object in (like bone shapes) that aren’t linked into any scenes but still have a non-zero user count so they get saved.

A while ago I wrote an operator that would clear out the ‘proper’ way but am way too lazy to search the forums for it now.

I’m using version 2.58, and the “save, exit Blender, reload” method wasn’t deleting them. That was my first thought and my first try. I don’t know who the “user” was, but for some reason they were not being removed by Blender … but I was able to use the script above and remove them one by one … :slight_smile:

Im using the latest version of Blender and never had your problem, good luck.

thanks Atom for a great example