Unloading Models

I’m having a problem unloadnig models. Here’s how I load my level model:
self.level = loader.loadModel(“environment.egg.pz”)
self.level.reparentTo(render)
self.level.setPos(0,0,0)

When I try self.level.destroy() it tells me there is no such attribute for the object type. How can I unload it/what is wrong?

removeNode panda3d.org/apiref.php?page=NodePath

If you entirely want to unload it from memory, you can use:

loader.unloadModel("environment.egg.pz")

But most likely you would mean what Treeform just said.

Ok, thanks for the help with that. I have one last question. To quit the program once it’s running, what command should I use. I’m using sys.exit right now, but for some reason it’s not working. I do not get an error, the command just does not execute. Is there another command I can use?

sys.exit is the actual way to quit your program. If it doesn’t work, something is really wrong. Once you imported sys, you can call sys.exit() anywhere and it should just quit. I don’t know why it wouldn’t work, are you sure you are not catching a SystemExit exception somewhere?

it happens to most people, I guess you didn’t really call sys.exitsize=150[/size]. Please respect the brackets !