TypeError: loadModel() missing 1 required positional argument: 'modelPath'

when i load models an error appears for all type of object files like .bam .gltf …

the code is :

load_prc_file(‘myConfig.prc’)

class TestAnim(ShowBase):

def __init__(self):

    ShowBase.__init__(self)  

    simplepbr.init() 

    self.arm = Loader.loadModel('/c/Users/ANASS/Desktop/PFE Master/object3d')

    self.arm.setPos(0,50,0)

    self.arm.reparentTo(self.render) 

app = TestAnim()

app.run()

In short, you’re calling the method “loadModel” from “Loader”–with a capital “L”–instead of from “loader”–with a lower-case “L”.

To explain, if I’m not much mistaken:

In this context, “Loader” refers to the “Loader” class itself. Conversely, “loader” is a global variable that stores an instance of that class.

As a result, when you call “Loader.loadModel”, you’re calling a version of the method that’s not bound to a specific instance of the “Loader” class. That means that the method isn’t provided the automatic “self” parameter that it would have had the method been called from an instance, leaving it one parameter short.

If instead you call “loader.loadModel”, you’re calling a version of the method that’s bound to the instance of the “Loader” class that’s stored in the global variable named “loader”. As a result, the automatic “self” parameter is provided along with your model file-name, and the method has its full complement of parameters.

1 Like

That’s right thank you for the reply

1 Like