Is there a way to check if its possible to switch blender mode? (Python API)

I’m working on an operator that does something that requires switching blender modes specifically from “edit” to “object” mode if the context is in edit. However if by chance this operator is invoked while a mesh operation is being done (like loop cut or bevel) attempting to switch causes blender to crash.

Is there a way to know at this current moment if it is safe to switch modes, or if some mesh operation is being done before attempting to switch?

I’ve been attempting a variety ways but none seem to be successful.

Any help is greatly appreciated.

What do you need to do in ‘object’ mode, specially while running a modal operator in ‘edit’ mode? :thinking:

1 Like

I have a modal operator that requires access to the mesh data, material, and changing some render settings while operating for a live update feature, so it gets a bit complicated in this case :sweat_smile:

prior to 4.2 you had to jump through many hoops to determine if there were any modal operators running, now it’s built into the api:

3 Likes