# Moving vertices in global coordinates

I need to move vertices along axis Z GLOBAL but I don't find how to do it. I've tried this:

ob = bpy.data.objects["object1"] #the vertices belong to object1
mat = ob.matrix_world
matloc = ob.matrix_local
for i in range( 0, len(poligonos) ):
v = mesh.getVertex(0, poligonos[i]) #poligonos is an array where I store the index of each vertex that I want to move
glo = mat * v.XYZ
glo.x = glo.x
glo.y = glo.y
glo.z = glo.z - 0.1
aux = matloc * glo
v.setXYZ([aux.x, aux.y, aux.z])


But this code moves my vertices to weird locations and what I need is the vertices go down in 0.1

Worked for me:

import bpy

obj  = bpy.data.objects['Cube']
mesh = obj.data
vert = mesh.vertices
mat_world = obj.matrix_world

pos_world = mat_world * vert.co
pos_world.z += 0.1
vert.co = mat_world.inverted() * pos_world


If you're editing a lot of vertices then you might want to compose the matrix:

from mathutils import Vector, Matrix

vec = Vector((0.0, 0.0, 0.1))
mat_edit = mat_world.inverted() * Matrix.Translate(vec) * mat_world

vert.co = mat_edit * vert.co


The answer of "pink vertex" is a great idea but finally I fixed the problem like this:

for i in range( 0, len(poligonos) ):
v = mesh.getVertex(0, poligonos[i])
glo = mat * v.XYZ
glo.z += 0.1
v.XYZ = mat.inverted() * glo