updating vertices positions

Does anyone know how to update the mesh position so that the new vertex positions are recorded. Or to put it another way why doesn’t this work.

import Blender
from Blender import Mesh

myverts = []
mesh = Mesh.Get("Plane")
verts = mesh.verts

def xyz(pos):
    pos = [pos[0], pos[1], pos[2]]
    return pos
for firstvert in verts:
    pos = xyz(firstvert.co)
for info in myverts:
    print info

It prints the x y z pos of each vertices fine but after moving vertices in the 3d view it doesn’t update thier positions.

Thats because it gets the position of the vertex in relation to the center of the object, not the center of the world. If you go into edit mode and move the verities and then go out of edit mode and rerun the script it will print different values.

Ok thanks, is there a way I can get them relitive to the world. If there isn’t allready a function don’t worry I can write my own.

Not that i know of, i guess you’ll just have to add in the location of the object to each verticies position.

Transform it by the object’s matrix, i.e.:

import bpy
import Blender

# Assumes your object is named Plane
ob = Blender.Object.Get('Plane')
me = ob.getData(mesh = True)
obMat = ob.matrix

for v in me.verts:
     print obMat * v.co

Will print in world coordinates. You have to use the matrix because the object could be rotated, scaled, or translated relative to the world (just adding the location of the object will only account for the translated part).