I'm writing an add-on for Blender, and I'd like to create two different key mappings for rotation: one will rotate around the median point, the other around the cursor. In each case, the plan is to set the pivot mode first, then enable rotation.

I can change the pivot point by setting bpy.context.scene.tool_settings.transform_pivot_point, but the next step is the manual rotation, which I can't figure out.

To be clear, I don't want to switch to the Rotate tool. I just want to do a quick rotation (as if the user pressed the R key); so once the rotation is confirmed, I want to switch back to whatever tool I was using before.

Is there an instruction in the Python API to trigger a manual rotation?

  • $\begingroup$ @curious_1 : "[...] works for me [...]" — But you need to call it from the invoke(), instead of execute() – right? Please, could you share some links on that topic? It would be useful either for me and for the author of the original question. $\endgroup$
    – Yaroslav
    Commented May 31 at 1:12
  • $\begingroup$ My goal is to allow the user to make an arbitrary, real-time rotation upon pressing a shortcut key, rather than do a specific preset rotation in the script. $\endgroup$
    – Latin1
    Commented May 31 at 3:09
  • $\begingroup$ @curious_1, so in your case you use a panel instead of the mouse-movement input. It's not quite the the thing we (Latin1 and me) were asking about. Though I'm grateful to you for your willingness to help. $\endgroup$
    – Yaroslav
    Commented May 31 at 11:35
  • $\begingroup$ @Yaroslav Can invoke() be used to query the rotation from the user? The docs have an example of a modal operator which can move the selected object when the script is executed. $\endgroup$
    – Latin1
    Commented May 31 at 18:30
  • $\begingroup$ I assumed triggering manual rotation mode would be pretty straightforward, but it looks like I may have to settle for adding a different hotkey that simply toggles between both pivot modes. $\endgroup$
    – Latin1
    Commented May 31 at 18:35


You must log in to answer this question.

Browse other questions tagged .