AttributeError: 'libpanda.PandaNode' object has no attribute

I have tow model: tut-2.egg and target.egg

card = loader.loadModel('target') # Load target.egg
card.reparentTo(render)
plane = BulletRigidBodyNode('Ground')
geomnodes = card.findAllMatches("**/*")

gn = geomnodes.getPath(0).node()
geom = gn.getGeom(0)
mesh = BulletTriangleMesh()
mesh.addGeom(geom)
plane.addShape(BulletTriangleMeshShape(mesh, dynamic=True))

It can run.

card = loader.loadModel('tut-2') # Load tut-2.egg
card.reparentTo(render)
plane = BulletRigidBodyNode('Ground')
geomnodes = card.findAllMatches("**/*")

gn = geomnodes.getPath(0).node()
geom = gn.getGeom(0)
mesh = BulletTriangleMesh()
mesh.addGeom(geom)
plane.addShape(BulletTriangleMeshShape(mesh, dynamic=True))

It’s wrong and print:

AttributeError: 'libpanda.PandaNode' object has no attribute 'getGeom'

run

print loader.loadModel('tut-2').ls()
print
print loader.loadModel('target').ls()
ModelRoot tut-2.egg
  PandaNode 
    GeomNode Cube.003 (1 geoms: S:(MaterialAttrib TextureAttrib TransparencyAttrib))
    GeomNode Landscape.003 (1 geoms: S:(MaterialAttrib TextureAttrib TransparencyAttrib))
None

ModelRoot target.egg
  GeomNode Cylinder (1 geoms: S:(MaterialAttrib TextureAttrib))
None

This may be wrong:

geomnodes = card.findAllMatches("**/*")

Try this:

geomnodes = card.findAllMatches("**/+GeomNode")

Tut-2 has its geoms under a PandaNode (as the ls() shows), it also shows it has 2 GeomNodes so you may want to walk all the nodes in the collection not just the first.

Thank you! It’s work !