I'm trying to write a function that returns vertex coordinates including their transformation that was a applied by (one or multiple) shape keys. Currently this is how I tried, but I only get vertex coordinates before the shape keys are applied:
def get_vertex_coords():
ob = bpy.data.objects['cc_base_body']
curmode = bpy.context.object.mode
bpy.ops.object.mode_set(mode='OBJECT')
mesh = ob.to_mesh(preserve_all_data_layers=True, depsgraph = bpy.context.evaluated_depsgraph_get())
bm = bmesh.new()
bm.from_mesh(mesh)
coords = []
for vertex in bm.verts:
if vertex.index in poi:
coords.append(vertex.co) # ob.matrix_world @
bpy.ops.object.mode_set(mode=curmode)
return coords
Is there any way to do this?
Thanks to the comments I found a way, see my posted answer.
bmesh.from_object
in OBJECT mode is the go here. $\endgroup$