Shortcut for scale with 0 along X/Y/Z (=align)

I would like to accelerate the command “S+X/Y/Z+0”, which I use very often. I do not like using the numpad, since that means letting go of the mouse or reaching over with my left hand.

The Idea: simply press hotkey, together with the needed axis button, in order to align without having to press Numpad 0.

Is there already a solution for this? if not, what would be the best approach?

Record a macro?

Assign a hotkey?

Write an app in Python?

Use geonodes Tools?

Use the already built in Ctrl R to repeat the last command?

Hope that helps.

You might have to choose some keyboard (and mouse?) recorder to assign for example the sequence of sx0 to something else what is not assigned in blender.

I tried Espanso to use for a “quick” backtick--x shortcut

  - trigger: "`x"
    replace: "sx0"

and deactivated blenders:

3D View:
wm.call_menu_pie -->  `

But this somehow interferes also with X → delete.. …so blender somehow gets “out of the keyboad queue” (??) and interpretes the keys differently as if typed manually…

…

And then i remembered about this (which may be overkill for you wishes ?):

…but i did’t assign this to any shortcut…

Hope that helps.

Im personally use this addon: MACHIN3tools
it have a functionality to “align” selected geometry to certain axis and i simply bind some of them to pie menu.

Thank you all for the responses! I wanted it to be a simple hotkey, so I decided to create a new operator using python. The other solutions you suggested were not “workflow-friendly” enough for my habits, but I wanted to test the waters to see what others are using. I’ll post the code here once I am done!

This is the script I am now using for it. It works well:

import bpy
from bpy.props import EnumProperty

class AlignToPivotOperator(bpy.types.Operator):
“”“Scale selection to align with the transform pivot point along a specified axis”“”
bl_idname = “transform.align_to_pivot”
bl_label = “Align to Pivot”
bl_options = {‘REGISTER’, ‘UNDO’}

axis: EnumProperty(
    name="Axis",
    items=[
        ('X', "X Axis", "Align along the X axis"),
        ('Y', "Y Axis", "Align along the Y axis"),
        ('Z', "Z Axis", "Align along the Z axis"),
    ],
    default='X',
)

def execute(self, context):
    axis_index = {'X': 0, 'Y': 1, 'Z': 2}[self.axis]

    # Ensure we're in Edit Mode
    if context.object.mode != 'EDIT':
        self.report({'ERROR'}, "Must be in Edit Mode")
        return {'CANCELLED'}

    # Apply scaling to zero along the specified axis
    bpy.ops.transform.resize(
        value=[0 if i == axis_index else 1 for i in range(3)],
        orient_type='GLOBAL'  # Use a valid orientation type like 'GLOBAL'
    )

    return {'FINISHED'}

def register():
bpy.utils.register_class(AlignToPivotOperator)

# Add keymaps
wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps.new(name='Mesh', space_type='EMPTY')

for axis in ['X', 'Y', 'Z']:
    kmi = km.keymap_items.new(
        AlignToPivotOperator.bl_idname,
        type=axis,
        value='PRESS',
        alt=True,
        ctrl=True
        #ALT AND CTRL ARE THE CURRENT SHORTCUT
    )
    kmi.properties.axis = axis

def unregister():
bpy.utils.unregister_class(AlignToPivotOperator)

# Remove keymaps
wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps.get('Mesh')
if km:
    for kmi in km.keymap_items:
        if kmi.idname == AlignToPivotOperator.bl_idname:
            km.keymap_items.remove(kmi)

if name == “main”:
register()

Hint:

It’s better to embed code with a triple backtick at the start and end or use Ctrl-e or use the preformatted text </>–icon in the WYSIWYG–editor tool bar.. maybe with an additional “file name” like so :wink: (copied from the previous history version enabled in raw format ) :

YouNameit.py ( AxisScaleShortCut.py ?? )

import bpy
from bpy.props import EnumProperty

class AlignToPivotOperator(bpy.types.Operator):
    """Scale selection to align with the transform pivot point along a specified axis"""
    bl_idname = "transform.align_to_pivot"
    bl_label = "Align to Pivot"
    bl_options = {'REGISTER', 'UNDO'}

    axis: EnumProperty(
        name="Axis",
        items=[
            ('X', "X Axis", "Align along the X axis"),
            ('Y', "Y Axis", "Align along the Y axis"),
            ('Z', "Z Axis", "Align along the Z axis"),
        ],
        default='X',
    )

    def execute(self, context):
        axis_index = {'X': 0, 'Y': 1, 'Z': 2}[self.axis]

        # Ensure we're in Edit Mode
        if context.object.mode != 'EDIT':
            self.report({'ERROR'}, "Must be in Edit Mode")
            return {'CANCELLED'}

        # Apply scaling to zero along the specified axis
        bpy.ops.transform.resize(
            value=[0 if i == axis_index else 1 for i in range(3)],
            orient_type='GLOBAL'  # Use a valid orientation type like 'GLOBAL'
        )

        return {'FINISHED'}

def register():
    bpy.utils.register_class(AlignToPivotOperator)

    # Add keymaps
    wm = bpy.context.window_manager
    km = wm.keyconfigs.addon.keymaps.new(name='Mesh', space_type='EMPTY')

    for axis in ['X', 'Y', 'Z']:
        kmi = km.keymap_items.new(
            AlignToPivotOperator.bl_idname,
            type=axis,
            value='PRESS',
            alt=True,
            ctrl=True
            #ALT AND CTRL ARE THE CURRENT SHORTCUT
        )
        kmi.properties.axis = axis

def unregister():
    bpy.utils.unregister_class(AlignToPivotOperator)

    # Remove keymaps
    wm = bpy.context.window_manager
    km = wm.keyconfigs.addon.keymaps.get('Mesh')
    if km:
        for kmi in km.keymap_items:
            if kmi.idname == AlignToPivotOperator.bl_idname:
                km.keymap_items.remove(kmi)

if __name__ == "__main__":
    register()

Also: If used as addon there is some need of something like:

bl_info = {
    "name":  "AxisScale",
    "version": (0, 1),
}

..then it is better findable after installation via Blender Preferences → Install..–button ( here: AxisScale)

( So it does install more easier with this but i still hadn’t figured out how to use it ? Only in edit mode.. yes.. should be a shortcut..but which one ?? But then i also didn’t looked too much into the code :sweat_smile: )

For extension this had changed..