Load model and unload model

Ok So I want to load A model so I do this

Test = loader.loadModel('the path to the object .bam')

But I want to unload it

Test = loader.unloadModel('the path to the object .bam')

But I don’t understand it gets an error! :frowning:

I get that error when I click the button to unload it and removeNode. I’m confused. Please Help! :cry:

You could try this:

Test = loader.unloadModel('the path to the object .bam')

I’m guessing that will still remove the model from cache, but I’m no expert.

Thanks for the code but it still doesn’t work now it says:

Are you shure you need to unload the model?
Unless the model is realy big (0.5GB+) or you have many (100+) models you use once and then remove them or the model file has changed since last you loaded it, then you usually don’t have to bother with unloading models.

Also I don’t think unloadModel returns any value, just do

loader.unloadModel('the path to the object .bam')

…if you really need to unload it.

Thanks it works!

Thanks but Is there away that it removes it from the scene but doesn’t delete it totally so I can use the model again?

Test = loader.loadModel()

I believe that the “detachNode” method does what you want.