Hi, I want to store the mesh select mode at the beginning of my script, then select some vertices via python (managed to do that), and then restore the select mode at the end. How to do that? I tried:
but that does not work. Also when I switch the select mode manually after the script ran, I lose my newly selected parts. The vertex selection does not convert to edge/face selection.
SELECTMODE = context.tool_settings.mesh_select_mode creates a reference to mesh_select_mode, and as you change it with python, SELECTMODE will always give you exactly that, the current state. So if you re-assign it, there’s of course no change.
Losing selections may happen with bmesh module, you need to manually flush some stuff. But if you do
ob.data.vertices[n].select = True
then there should be no problem, only if you switch from vertex to edge/face selection mode, edges/faces with not all verts selected won’t get selected and parts of your original selection get lost due to this.