Here I found a working solution using ctypes which allows to find out if any modal operator is currently running. I am not good in C and don't understand how it works. But I'm sure someone does, so is there a way to find out exactly which modal operators are currently running, and get a list of them (or their bl_idname)? As the Blender API only provides a few bpy.app.handlers which cover only several specific cases this would be a nice solution to make custom handlers for all other modal operators not included in the bpy.app.handlers.

For example for my add-on I would like to launch from my custom Modal Operator bpy.ops.render.opengl Operator in series in ('INVOKE_DEFAULT') mode to be able to see a preview and abort this process at any time - but there's no handler in the API which would tell me when bpy.ops.render.opengl is over, and I can't figure out how to catch the moment when it returns {"FINISHED"}.

  • $\begingroup$ By the way it seems the first Ctypes solution works only with Python Operators in Blender. I've tried to launch bpy.ops.render.opengl('INVOKE_DEFAULT'), which is written in C as I know, and use this solution together with threading.Timer() to catch the moment where all modal operators stop running. And it doesn't catch any modal operator while bpy.ops.render.opengl is in progress. Pity, it could be a workaround. $\endgroup$ – Andrey Sokolov Aug 11 '20 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.