AttributeError: 'panda3d.core.PandaNode' object

Greetings All,
I’ve defined a delete function with the attached code to delete images I rendered by Panda3d.
But when I called the delete function, all give me the following error:
AttributeError: ‘panda3d.core.PandaNode’ object has no attribute ‘getFullpath’

[*]Running Panda3d 1.9.2 with Ubuntu 14.04 64bit on server.
function code

def delete(self):
        self.alnp.removeNode()
        for n in self.light_nodes:
            n.removeNode()
        for m in self.models:
            self.loader.unloadModel(m)
        base.destroy()

Output

File "renderer.py", line 75, in delete
    self.loader.unloadModel(m)
  File "/anaconda2/lib/python2.7/site-packages/direct/showbase/Loader.py", line 289, in unloadModel
    assert Loader.notify.debug("Unloading model: %s" % (modelNode.getFullpath()))
AttributeError: 'panda3d.core.PandaNode' object has no attribute 'getFullpath'

Any help would be appreciated.

It looks like you are passing a PandaNode to loader.unloadModel, while it expects the ModelRoot that was returned by loader.loadModel.

Oh, thanks! But how can I solve this problem?

When you load a model, using loader.loadModel(“my_model”), the returned object is a hierarchy of Panda objects, the root of which is normally a ModelRoot object. You can see this when you call ls() on that object:

self.model = self.loader.loadModel('smiley')
model.ls()

output:

ModelRoot smiley.egg
  GeomNode  (1 geoms: S:(TextureAttrib))

So self.model can be passed to self.loader.unloadModel since it is a ModelRoot object.

Why your models in self.models contain PandaNode objects, I don’t know, but you will need to keep the originally loaded models (ModelRoot objects) around if you want to unload them.
Alternatively, it should be possible to pass the filename that was passed to loadModel(), but this is mainly for backward compatibility and requires a disk search.