Hey,
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.
bpy.context.object.data.vertices[0].co
I think there are two options
There is a simple function to get a vertex’s animated position
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.
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.
bpy.ops.object.mode_set(mode=“EDIT”)
bpy.ops.mesh.select_all(action=“SELECT”)
bpy.ops.mesh.quads_convert_to_tris()
bpy.ops.object.mode_set(mode=“OBJECT”)
Is there any way to do something like this?
m = bpy.context.object.to_mesh(bpy.context.scene,True,‘RENDER’)
bpy.ops.mesh.quads_convert_to_tris(m)
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
bpy.ops.mesh.quads_convert_to_tris()
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.