deleting objects

This is a pretty dumb question - how do I delete a Blender object from Python? -or- If I have an existing mesh object, how do I delete it?

RS

Got it!:stuck_out_tongue:

ob = Object.Get('Blender_object_name')
sc = Scene.getCurrent()
sc.unlink(ob)

RS

Yeah just remember that it unlinks and doesn’t delete, so to really get rid f the object you’ll have to save/reload the blender file

in Blender deleating will remove the object from the library to save memory, as long as it has 0 users of course.

But in BPython, the python object is a user, so even if an objects not in a scene, it will have 1 user - that is the python object, when python decref’s that, it may be removed Im not sure.

Cambo,

Unlinking an object does not (necessarily?) cause the object to be removed from memory after the file is reloaded! I did a

print(Object.Get())

and discovered over twenty hidden “Mball*” objects sitting there in my scene. Of course, if you make a new metaball with the same name as one that’s already existing, it doesn’t show up!

I would like to lobby for a real “delete” method.

RS

The reason this makes no sense - how do I reuse objects? If I re-link them, they’ll bring with them whatever meshes they had linked to them before, won’t they? There doesn’t seem to be a way of unlinking meshes from objects, but maybe I’m missing something.

So - if I want to use an object 200 times in the same place I need to make 200 unique names? Are the other 199 still sitting around in memory taking up space?

Hrrrmmmm…

RS

can you make a bug report with detailed steps to follow. even a pyScript that makes the objects and then instructions as to save/resave.

if your using the interactive console- it may be storing objects that take a user slot at the time you hit save. See if you can find out the user count in the data browser of print ob.users so you can see if its not de-allocing 0 user objects.

Cambo,

I couldn’t recreate the persistant objects - I’ll keep an eye on that one. Here’s code for my metaball delete problem"

import Blender

scn = Blender.Scene.GetCurrent()

for i in range(10):
    MetaObj = Blender.Object.New("Mball","Mball")
    mb = Blender.Metaball.New()
    mb.elements.add()
    MetaObj.link(mb)
    scn.link(MetaObj)
    scn.unlink(MetaObj)

MetaObj = Blender.Object.New("Mball","Mball")
mb = Blender.Metaball.New()
mb.elements.add()
MetaObj.link(mb)
scn.link(MetaObj)

results in…no metaballs! The appending of “.001” to an already existing name works fine for meshes, but with metaballs it makes Blender think that the object is a sub-object of the original - which is not linked into the scene!

RS