I'm making a custom modal rotation operator which raps around a standard bpy.ops.transform.rotate() operator. The purpose is to create a pause when the object being rotated by the user gets close enough to a base of 30 degrees (visual auto contextual snapping).

Would like to do this without completely writing a new rotation operator. Or losing the visual bgl elements provided with the existing transform.rotate operator. I'm currently invoking transform.rotate from within my modal operator. I'm aware I could not invoke transform.rotate and instead feed it incremented values from my modal operator and mouse screen data, but I'd lose the bgl elements from the standard rotate operator (dashed lines, arrow icons etc). Would also turn this into a much more complicated project...

The issue lies in trying to monitor and affect the main modal operator (my custom rotation operator) while running transform.rotate within it. I've discovered this can be overcome with a scene_update_post app handler during initial execution of my modal operator. In this way, I'm able to retrieve live data about object rotation (or anything else I want) while running transform.rotate (itself a modal operator) from within my modal operator which is awesome!

Now that I have access to the rotation data as it's being performed via scene_update_post is there any way I can use that to finish or interrupt transform.rotate? Is there a better way to monitor modal operators like transform.rotate from within your own modal operator (while being used, not post or pre)? Sorry, for not having a code example, the overall system's pretty verbose. Don't fret to much over this one. Just curious if any experts know of some fancy tricks.

  • $\begingroup$ Stupid question: Have you tried a global variable? $\endgroup$ – B.Y.O.B. Apr 6 '18 at 7:13
  • $\begingroup$ @B.Y.O.B. Not stupid at all. Yes, tried using bools attached to scene and the window manager (assuming you meant something like that). I didn't frame this question very well. The issue is not really "how do I communicate with the modal operator", it's more how can I interrupt (finish or cancel) a modal operator via code... rather than waiting for the user to finish (in this case rotate). I'm trying another approach now though. I should have recognized this question was to mushy. Over stepped my reach a bit. I'll try to be more condensed & have a code example next time. $\endgroup$ – Sicut Unum Apr 10 '18 at 17:02
  • $\begingroup$ Any progress on this? I'm looking to do something similar. $\endgroup$ – andyV Jul 21 '18 at 2:02

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.