To get the active element, use
To set an active element, use
The last added element will be active, provided that it’s selected.
bm.select_history.validate() after changes to ensure that only selected elements are in
Update the edit mesh afterwards.
Example that clears the active list and sets an edge (
bm.edges) to active:
me = bpy.context.object.data
bm = bmesh.from_edit_mesh(me)
edge = bm.edges
edge.select = True # select the element before making it active
bm.select_history.clear() # optionally clear previous elements