You can access all of Blenders mesh data with bpy.data.objects[i].data
. However this data can't really be edited as you do in edit mode. When you switch to edit mode, a whole new object (at codelevel) is temporarily created untill you exit edit mode and return to object mode. When you return to object mode, the temporary edit mesh is converted to an object mode mesh.
This means while you are in edit mode, the changes you see are not reflected in yourObject.data
. yourObject.data
only contains the object mode mesh. It will be updated once we exit edit mode.
You could add the lines to update the object mode mesh, before printing its data.
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.mode_set(mode='EDIT')
But this only adds unnecessary overhead to your operations. (And you shouldn't be using the bpy.ops functions anyways.)
The solution is to use the bmesh module, it is designed to handle mesh data and has calls to update it.
Import it with import bmesh
.
Then get the object data with me = bpy.context.object.data
Getting and setting the object data is dependant on which mode we are in.
Edit Mode
bm = bmesh.from_edit_mesh(me)
# manipulate the mesh data with the bmesh reference here
bmesh.update_edit_mesh(me, False, False)
Object Mode
bm = bmesh.new()
bm.from_mesh(me)
# manipulate the mesh data with the bmesh reference here
bm.to_mesh(me)
me.update()
If you don't know, wether you are in edit or object mode, when your script executes, use this answers code (last block). It will check if the object is in edit mode and use the according functions.