Hello, I am relatively new to Panda3d and had scripting issues. I think I found a workaround now but was hoping someone here could clarify panda’s behavior for me, as it really felt a little bit erratically to me.
When I tried to reparent or attach nodes to joints of my model, I would often get the error “argument 1 must be panda3d.core.NodePath, not NoneType”. However, depending on the functions within my code I am making the call from, it can also work without issues.
An example would be this test here I made:
In this function of a class wich first loads a model and then attaches additional nodes on the joints, I added a testJoint and then attached a testNode. No issues within the loop.
def setupLights(self):
for item in self.lights:
slight = Spotlight('slight'+item[0])
slight.setColor((1, 1, 1, 1))
lens = PerspectiveLens()
#lens.setFov(150)
slight.setLens(lens)
#slight.showFrustum()
#slight.setAttenuation((1, 0, 0.1))
slnp = render.attachNewNode(slight)
slnp.setPos(0, 0, 0)
slnp.reparentTo(item[1])
#slnp.reparentTo(self.obj.exposeJoint(None, "modelRoot",jointName = "Main_Thruster_Star_Prefire")) #for testing
slnp.lookAt(self.obj.exposeJoint(None, "modelRoot",jointName = item[0]+"_Tail"))
self.obj.setLight(slnp)
testJoint = self.obj.exposeJoint(None, "modelRoot",jointName = "Main_Thruster_Star_Prefire")
testNP = testJoint.attachNewNode("NPTest")
#end setupLights()
Now I just moved testJoint and testNP outside the loop and testJoint suddenly becomes a NoneType.
def setupLights(self):
for item in self.lights:
slight = Spotlight('slight'+item[0])
slight.setColor((1, 1, 1, 1))
lens = PerspectiveLens()
#lens.setFov(150)
slight.setLens(lens)
#slight.showFrustum()
#slight.setAttenuation((1, 0, 0.1))
slnp = render.attachNewNode(slight)
slnp.setPos(0, 0, 0)
slnp.reparentTo(item[1])
#slnp.reparentTo(self.obj.exposeJoint(None, "modelRoot",jointName = "Main_Thruster_Star_Prefire")) #for testing
slnp.lookAt(self.obj.exposeJoint(None, "modelRoot",jointName = item[0]+"_Tail"))
self.obj.setLight(slnp)
testJoint = self.obj.exposeJoint(None, "modelRoot",jointName = "Main_Thruster_Star_Prefire")
testNP = testJoint.attachNewNode("NPTest")
#end setupLights()
There also weren’t any issues yet when I only setup the nodes and joints within the Class and afterwards reparent from my main applycation.