Take the 2-minute tour ×
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Worked for me:

import bpy

obj  = bpy.data.objects['Cube']
mesh = obj.data
vert = mesh.vertices[0]
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
share|improve this answer

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.