Update mesh after using bmesh in object mode To avoid some unnecessary OBJECT/EDIT mode toggle, i'd like to be able to perform some actions via Bmesh in object mode.
Is it possible to update apply changes after a Bmesh action in object mode ?
For exemple, i try to select an edge with this little code but, without update, the edge not selected.

import bpy
import bmesh

C = bpy.context
ob = C.object
me = ob.data
bm = bmesh.new()
bm.from_mesh(me)

bm.edges.ensure_lookup_table()
bm.edges[2].select = True

# need to update here

bm.free()
del bm
Try:

# need to update here
bm.to_mesh(me)


But then you'll need to switch to edit mode to see the selection.

As an alternative, you can do the selection entirely in edit mode with the following:

mesh = bpy.context.object.data
bm = bmesh.from_edit_mesh(mesh)

bm.edges.ensure_lookup_table()
bm.edges[2].select = True

bmesh.update_edit_mesh(mesh)