How to update mesh data in edit mode?

I’m writing a modal operator that I’d like to run in edit mode, since it needs to deal with individual vertices. I also have the modal() method of my operator returning 'PASS_THROUGH' in most cases so that it is possible to select and move vertices while my operator is running. I’ve just noticed, though, that if I do so that any changes that I make are not reflected in the mesh data. If I tab into Object mode and then back into Edit mode, then the object’s data is updated and the selection and position of vertices returned from object.data are correct - however, if I stay in edit mode the mesh data does not change even after selecting or moving vertices.

Is there a way to force an update without leaving edit mode?

use

is_success_update_data = object.update_from_editmode()

more information : https://docs.blender.org/api/current/bpy.types.Object.html#bpy.types.Object.update_from_editmode

2 Likes