Possible to modify the rotate tool?

I want to add feature to this context based mode that appears once you hit “R”. Basically once Rotate mode is active if you press

1 key = obj.rotation_euler[0] += 1.5708
2 key = obj.rotation_euler[1] += 1.5708
3 key = obj.rotation_euler[2] += 1.5708

So basically you can enter “R” to rotate, then quickly spin the object by 90c on z,x,y axis by pressing keyboard 1,2,3 keys.

What would be the best approach here? Is there a way I can modify or add something custom to this list?

image

You would need to write your own rotate modal operator first.

In that operator you would check for each key press (key event 1, 2, 3), and if it detects that it can apply the rotation you outlined above (1.5708), and then either: exit the modal operator so that you would need to press ‘R’ then a number to enter a second rotation, or stay in the loop allowing the user to continue rotating with 1, 2, 3, but necessitating an ‘exit’ key, like ‘ESC’.

Then, you would unbind ‘R’ from Blender’s rotate and re-bind it to your own rotate modal operator.

In the Text Editor, check out Templates > Python > Operator Modal to see an example of how to handle key events and how to enter and exit the modal loop.

1 Like