moving vertices in a mesh using Blender 2.49

Hello,

I’m trying to animate a mesh(using ShapeKeys)

The plan is to:

  • insert a key(the basis key)
  • go to edit mode
  • move the vertices
  • insert a key
  • exit edit mode
  • if there’s a previous key, set it’s ipo key bezier value to 0.0
  • set the current key value to 1.0

At the moment I tried to move the vertices by switching the editmode, looping through the mesh vertices and just updating each memeber:

mesh = ob.getData()
if editmode:    Window.EditMode(0)
for v in range(0,232):
    mesh.verts[v][0] = verts[0][v][0]
    mesh.verts[v][1] = verts[0][v][1]
    mesh.verts[v][2] = verts[0][v][2]
ob.insertShapeKey()
if editmode:    Window.EditMode(1)

ob would be the current object, and verts is a list of vertices for each shape key.

To keep this short, once I’ve defined a mesh:
can I got edit mode, end edit the mesh(vertices) ?
If so, how ?

Thanks

Ok, either I store the new vertices as a list of MVerts and just do something like

mesh.verts = newVerts

or use the .co property to update x,y,z, if the new vertices are stored as plain vectors(e.g. [0.0,0.0,0.0])

mesh = ob.getData()
if editmode:    Window.EditMode(0)
for v in range(0,232):
    mesh.verts[v].co.x = verts[0][v][0]
    mesh.verts[v].co.y = verts[0][v][1]
    mesh.verts[v].co.z = verts[0][v][2]
ob.insertShapeKey()
if editmode:    Window.EditMode(1)