As shown in the following image, we created a 3D model of a car in Blender and divided it into three objects: the rough car part, the roof and sides, the rear window part, and the tires, and also prepared several vertex groups. enter image description here

What I want to achieve

I would like to create a system in which Bpy selects a group of vertices, and changes the coordinates of the selected vertex group to change the shape of the car.


I am having trouble understanding how to load a vertex group in Bpy and change the coordinates of the selected vertex group.

Supplemental information (FW/tool version, etc.)

Version Blender:2.93.5


1 Answer 1


The following two examples should help you:

  1. Templates > bmesh_simple_editmode,
  2. https://docs.blender.org/api/3.4/bmesh.html#customdata-access .
# This example assumes we have a mesh object in edit-mode

import bpy
import bmesh


# Get the active mesh
obj = bpy.context.edit_object
me = obj.data

# Get a BMesh representation
bm = bmesh.from_edit_mesh(me)

# in this example the active vertex group index is used,
# this is stored in the object, not the BMesh
group_index = obj.vertex_groups.active_index

# only ever one deform weight layer
dvert_lay = bm.verts.layers.deform.active

for vert in bm.verts:
    dvert = vert[dvert_lay]

    if group_index in dvert:
        vert.co.x += 1

# Show the updates in the viewport
# and recalculate n-gon tessellation.
bmesh.update_edit_mesh(me, loop_triangles=True)

  • $\begingroup$ Thank you very much for your help. How can I manipulate a vertex group to which I have given a name in advance, instead of manipulating the active vertex group? $\endgroup$
    – くれあ
    Jan 22, 2023 at 7:10
  • $\begingroup$ @くれあ OK. Use group_index = obj.vertex_groups.find('Group Name'). $\endgroup$
    – tetii
    Jan 22, 2023 at 9:10
  • $\begingroup$ Thanks to you I was able to implement the feature. Thank you very much. $\endgroup$
    – くれあ
    Jan 22, 2023 at 10:15

You must log in to answer this question.

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