Cannot call ___ on a const object

I’m trying to retrieve the vertices from a geom, and add the world coordinates, but I keep getting this const error.

Traceback (most recent call last):
  File "", line 92, in <module>
  File "", line 72, in checkIntersection
    v += intoGeomNode.getParent(0).getTransform().getPos()
TypeError: Cannot call VBase3.__iadd__() on a const object.

Here’s how I get the vertices:

  for i in range(geomNode.getNumGeoms()):
    geom = geomNode.modifyGeom(i)
    vdata = geom.modifyVertexData()
    vReader = GeomVertexReader(vdata, 'vertex')
    for p in range(geom.getNumPrimitives()):
      prim = geom.modifyPrimitive(p)
      while not vReader.isAtEnd():
        vtx = vReader.getData3f()
        if vtx not in vtxList:

…and here’s how I’m trying to add to them…

v += intoGeomNode.getParent(0).getTransform().getPos()

David mentioned setting commands like .getGeom() to .modifyGeom(), but I still have the error. I was referring to this post:

The error message is telling you that your VBase3 object is constant, and therefore cannot be modified in-place. That is to say, your VBase3 is not a unique VBase3 object on its own, but is rather a shared pointer into someone else’s memory, which you cannot modify. The operation:

v += intoGeomNode.getParent(0).getTransform().getPos()

is an in-place modification of v. Replace this with:

v = v + intoGeomNode.getParent(0).getTransform().getPos()

which replaces v with a new instance instead. Or, when you get v in the first place, wrap a VBase3 around it:

v = VBase3(v)


That worked perfectly-

Thanks, David!