Python Code to activate Transform action and locking local x-axis???

So I have found myself needing to fix some topology issues more and more on my loader arm project for the Heavy Equipment stream and wanted to use Python to make a shortcut that will activate the transform on a selected vert/edge/face and lock movement in x but allow y and z.


Hitting G then Shift + x over and over has gotten really tiresome and I was wondering if there is a simple python line I could assign to a keyboard shortcut or one of my extra mouse buttons?


I tried looking over in the console but the code does not populate until after I complete the transform move and if I use that it just moves the object for me. I want the transform to be active so I can decide where it goes if that makes sense.

  • spikeyxxx replied

    Hi Shawn, what you could do is go to Preferences > Keymap > 3D View > 3D View (Global) and make an extra Move shortcut like so:

    (at the bottom where it says: +Add New) 

    Don't use G for this one of course, but any free key could do the trick.

    I do not know how to do this with Python, but I dare say that it will be a lot more work to make a new Operator (Sybren Stüvel made an Operator episode in his 'Scripting for Artists' series).

  • Shawn Blanch(blanchsb) replied

    That's perfect spikeyxxx  I got some books on Python and the code isn't terrible to follow but I don't know if enough to be trying things out on my own.


    I was hoping to stretch my python wings just a smidge. And thought this would be a great place to ask.


    This is a perfect solution though. Thanks!

  • Shawn Blanch(blanchsb) replied

    Here's my solution based on your feedback. Do you know what mirror editing checkbox does? Is that same as X-mirror?

  • spikeyxxx replied

    Didn't know about this Mirror Editing, but when checked and having one or more axes enabled it moves the mirrored vertices (when there are any) together with the selected ones:

    It's like mirror option in Sculpting. It appears to also do this when using the Move Gizmo (when the Mirror Editing checkbox is un-checked), but not when using the G hotkey...

  • Shawn Blanch(blanchsb) replied

    Hmmmmmmm........Yeah I noticed when I push some of those check boxes that it overrides the Viewport options a little more than I realized. I ended up unchecking all of them in the Keymaps except the constrain to YZ.

    Thanks spikeyxxx