How can I update/modify the xyz coordinates of a vertex group. I can get the vertex coordinates of the vertex group. BUT, what I want to do is reassign or move the vertex coordinates to a new list of coordinates.

I'm completely lost. It seems that I have the right context and data, but then I cannot figure out how to update/change the coords of the vertices. I've tried a number of things.

So here is the code raw. I first get the coords of the target vertices which are selected in the viewport (object), then I 'get' and print the vertices of the vertex group that I want to update coordinates to (see code). BUT I can't figure out how to update the vertex coordinates. It's probably a noob easy-do but I can't figure it out!! Any help thanks!!! I'm going crazy here trying to figure this out.

import bpy
import bmesh

obj = bpy.context.active_object
objdata = bpy.context.active_object.data

vertices = obj.data.vertices
vertstarg = [obj.matrix_world * vert.co for vert in vertices] 

# coordinates as tuples if needed
vertstargtup = [vert.to_tuple() for vert in vertstarg]

for obj in bpy.data.objects:
    obj.select = False

#holy cow. have to make the object active before selecting. makes sense now.
bpy.context.scene.objects.active = bpy.data.objects['crvface.001']  
bpy.data.objects['crvface.001'].select = True

obcage = bpy.context.object

bpy.ops.mesh.select_all(action = 'DESELECT')

vgVerts = [ v for v in obcage.data.vertices if v.select ]


#Ok so clearly I can access the vertices of obcage.data vertex group, 
#but how to I update the coords from objcage.data.vertices to the list from
#vertstarg, which is a list of vector coords [or tuples if needed]???
  • $\begingroup$ Thanks for all advice; I checked out the vids and stuff/info in the replies, but these are very simple things that I'm reasonably familiar with. What I can't do is set or modify the vertexes of the vertex group. I'm sure there must be some way to access the '.co' but cant figure it out still... $\endgroup$
    Commented Oct 26, 2018 at 2:20

2 Answers 2


Your script is going into edit mode, so you need to use bmesh to update the edit mesh data.

bm = bmesh.from_edit_mesh(obj.data)
for v in bm.verts:
    v.co = (v.co.x + 0.2, v.co.y + 0.2, v.co.z + 0.2)

You can directly access each component of each vertices location.

v.co.x += 0.2
v.co.y += 0.2
v.co.z += 0.2

You can leave the object in object mode and still work with bmesh data -

bm = bmesh.new()

for v in bm.verts:
    v.co.x += 0.2


As you only want to move the vertex locations, you don't need any bmesh features, so you could leave the object in object mode and edit the mesh data directly, this is the vertex data you get in vgVerts. If you change this data directly while in edit mode, the edit mesh will overwrite any changes.

for v in obj.data.vertices:
    if v.select:
        v.co = (v.co.x + 0.2, v.co.y + 0.2, v.co.z + 0.2)
  • $\begingroup$ Thanks very much for this. I think I understand now. Much appreciated. $\endgroup$
    Commented Oct 26, 2018 at 14:30

tuples are read only you cant reasign its value. try to use to_list() instead... i think. [list(vert) for vert in vertstarg] then seems like you are doing nothing to your verts but selecting

grab the header bar down (the file menu) to see some info from operators. or go to de scripting window, there is on the top also. almost every thing you do inside blender is shown on that "console" see https://www.youtube.com/watch?v=2j75AM1Mttc

  • $\begingroup$ Yes that is just selecting. What I need to do is reassign the new coords to the the selected vertex group list. Tuples are not necessary just included as an option. I can remove tuples and does not change the workflow. Thanks for your help. $\endgroup$
    Commented Oct 25, 2018 at 21:14
  • $\begingroup$ if u do print(dir(vgVerts)) it shws all the methods avalables for that object, you just probably can do: for vert in vgVerts: "\n" something like vert.location or vert.position = [0,0,0] # this is the x y z values. $\endgroup$
    – Javier
    Commented Oct 25, 2018 at 22:01
  • $\begingroup$ youtube.com/watch?v=3Q9lTBZFfp0 $\endgroup$
    – Javier
    Commented Oct 25, 2018 at 22:07
  • $\begingroup$ Did the print(dir...), here's what I get. Can't find or set the vertex data from this. >>> print(dir(vgVerts)) ['add', 'class', 'contains', 'delattr', 'delitem', 'dir', 'doc', 'eq', 'format', 'ge', 'getattribute', 'getitem', 'gt', 'hash', 'iadd', 'imul', 'init', 'iter', 'le', 'len', 'lt', 'mul', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'reversed', 'rmul', 'setattr', 'setitem', 'sizeof', 'str', 'subclasshook', 'append', 'clear', ...] $\endgroup$
    Commented Oct 26, 2018 at 1:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .