Location of deformed/animated vertex

I need to get the location of a vertex after it has been moved by an armature.

Unfortunately the code below only returns the vertex location as it is in edit mode, not pose/object mode.


I think there are two options

  1. There is a simple function to get a vertex’s animated position
  2. I’ll have to multiply the vertex location by the armature’s bone transform matrices and weight each by the vertex group weights. If this is the only option, I’d appreciate some example code on how to do it.


You can constrain or parent an object to the vertex. Then use the world matrix to get its location.

There is also the object.to_mesh method.

Try this in console (mesh selected)

>>> ob = C.object
>>> scn = C.scene
>>> mesh = ob.to_mesh(
>>> mesh = ob.to_mesh(scn,True,'PREVIEW')

returns a mesh deformed to how you see it.

Thanks, that does the trick.

One followup question:

Once I’ve created that new mesh, how can I programmatically convert its quads to tris?
I’ve seen some people do it this way, but the problem with this is that you must have a owning object of the mesh in order to go into edit mode.

Is there any way to do something like this?
m = bpy.context.object.to_mesh(bpy.context.scene,True,‘RENDER’)

I see what you mean.

newobject = bpy.data.objects.new("newobj",m) #new object with the new mesh
context.scene.objects.link(newobject)  #not sure if you need this.  Links the object to scene think you do need it to go into edit mode.
bpy.ops.object.select_name("newobj")  #it now has context
bpy.ops.object.mode_set(mode="EDIT")  #needs to be in edit mode for mesh ops

Operators generally work on the context object. Rather than passing it the object … bpy.ops.mesh.someop(mesh), you get the mesh into context then use the operator Bit confusing at first it “clicks” and makes sense after a while… A lot of things can be done in the API without using ops.