Why does a mesh object return an empty vertex collection when in Edit Mode? As you can imagine my forehead is a bit bloody from this noodling and want to understand why the following access to data.vertices
is dependent on mode. Here you see the same print statements before and after the editmode_toggle
:
bpy.ops.mesh.primitive_plane_add( size=sizeR, location=locat, scale=(1, yScale, 1), enter_editmode=True )
bpy.ops.mesh.select_all( action='SELECT' )
bpy.ops.mesh.subdivide( number_cuts=12 )
# randomly select a portion of the vertices and move them along the Z axis (to create shadows)
obj = bpy.context.active_object
print( str(obj.data ) + " vertices=" + str( obj.data.vertices ) )
bpy.ops.object.editmode_toggle()
prints:
<bpy_struct, Mesh("Plane.008") at 0x000001FFE8F782D8> vertices=<bpy_collection[0], MeshVertices>
<bpy_struct, Mesh("Plane.008") at 0x000001FFE8F782D8> vertices=<bpy_collection[196], MeshVertices>
i.e, an empty collection when in Edit Mode, but a complete set of (196) vertices in Object Mode.
Thanks for any insight.