Hi,
I’ve trying to get into the Python API. BMesh especially interests me. However I can’t seem to get my head wrapped around the update_edit_mesh() method. I’ve tried writing a piece of code which will take a plane (in EDIT mode) and translate it 10 BU’s along the x-axis (Please excuse the “triviality” of the job to be done - it is merely illustrative…)
Now, I’m calling update_edit_mesh() at the end of each loop iteration. What I expect to see is the mesh updating 10 times - much like 10 frames of animation. However, what I see is only the last frame.
Could you please point out what I am missing? I am not a core programmer, so you might have to be patient with me!
import bpy
import bmesh
import mathutils
plane = bpy.context.object.data # get selected object
bplane = bmesh.from_edit_mesh(plane) # create BMesh in EDIT mode
cv = len(bplane.verts) # get number of vertices
g = 0 # initialise loop counter
while (g < 10):
for i in range(0, cv): # ...for every vertex...
bplane.verts[i].co += mathutils.Vector((1, 0, 0)) # add x-translation of 1 BU
g += 1 # increment loop counter
bmesh.update_edit_mesh(plane, False, False) # update calculations to mesh
I have even tried adding a delay loop within the main loop just to see if its happening too fast - but to no avail. Any assistance would be greatly appreciated. Thanks in advance.
Regards
Anurup