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

**URL:** <https://blenderartists.org/t/shortcut-for-scale-with-0-along-x-y-z-align/1560742>\
**Category:** Modeling\
**Tags:** modeling\
**Created:** [December 2, 2024, 9:22am UTC](https://blenderartists.org/t/shortcut-for-scale-with-0-along-x-y-z-align/1560742 "2024-12-02T09:22:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavesDesigns](https://blenderartists.org/letter_avatar_proxy/v4/letter/d/71e660/32.png) [@DavesDesigns](https://blenderartists.org/u/DavesDesigns)\
**Post date:** [December 2, 2024, 9:22am UTC](https://blenderartists.org/t/shortcut-for-scale-with-0-along-x-y-z-align/1560742/1 "2024-12-02T09:22:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![AlphaChannel](https://blenderartists.org/user_avatar/blenderartists.org/alphachannel/32/1432111_2.png) [@AlphaChannel](https://blenderartists.org/u/AlphaChannel)\
**Post date:** [December 2, 2024, 10:33am UTC](https://blenderartists.org/t/shortcut-for-scale-with-0-along-x-y-z-align/1560742/2 "2024-12-02T10:33:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Okidoki](https://blenderartists.org/user_avatar/blenderartists.org/okidoki/32/1434104_2.png) [@Okidoki](https://blenderartists.org/u/Okidoki)\
**Post date:** [December 2, 2024, 10:43am UTC](https://blenderartists.org/t/shortcut-for-scale-with-0-along-x-y-z-align/1560742/3 "2024-12-02T10:43:42Z")

</div>

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

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

```

and deactivated blenders:

```auto
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 ?):

> **[GitHub - InamuraJIN/ActionRecorder](https://github.com/InamuraJIN/ActionRecorder)**
>
> Contribute to InamuraJIN/ActionRecorder development by creating an account on GitHub.

 ![RecordedMacro](https://blenderartists.org/uploads/default/original/4X/3/b/f/3bf2ed0649cb869e1f1c8cb0688a5371d719f6eb.jpeg)

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

---

<div class="post-metadata">

**Author:** ![AlphaChannel](https://blenderartists.org/user_avatar/blenderartists.org/alphachannel/32/1432111_2.png) [@AlphaChannel](https://blenderartists.org/u/AlphaChannel)\
**Post date:** [December 2, 2024, 11:39am UTC](https://blenderartists.org/t/shortcut-for-scale-with-0-along-x-y-z-align/1560742/4 "2024-12-02T11:39:18Z")

</div>

![image](https://blenderartists.org/uploads/default/original/4X/1/0/5/105dec1b7c129e64f0b27d906a14d56f5542f267.png)

[![](https://blenderartists.org/uploads/default/original/4X/e/0/a/e0a1016d542c8a2874db0c71cd864eb6938cdf8a.jpeg "Introduction to Node Tools in Blender 4.0!") ](https://www.youtube.com/watch?v=Y8Udi1AkdGY)

Hope that helps.

---

<div class="post-metadata">

**Author:** ![SoundDifferent](https://blenderartists.org/letter_avatar_proxy/v4/letter/s/ed8c4c/32.png) [@SoundDifferent](https://blenderartists.org/u/SoundDifferent)\
**Post date:** [December 2, 2024, 12:03pm UTC](https://blenderartists.org/t/shortcut-for-scale-with-0-along-x-y-z-align/1560742/5 "2024-12-02T12:03:50Z")

</div>

Im personally use this addon: [MACHIN3tools](https://blenderartists.org/t/machin3tools/1135716)  
it have a functionality to “align” selected geometry to certain axis and i simply bind some of them to pie menu.

---

<div class="post-metadata">

**Author:** ![DavesDesigns](https://blenderartists.org/letter_avatar_proxy/v4/letter/d/71e660/32.png) [@DavesDesigns](https://blenderartists.org/u/DavesDesigns)\
**Post date:** [December 3, 2024, 10:45am UTC](https://blenderartists.org/t/shortcut-for-scale-with-0-along-x-y-z-align/1560742/6 "2024-12-03T10:45:51Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![DavesDesigns](https://blenderartists.org/letter_avatar_proxy/v4/letter/d/71e660/32.png) [@DavesDesigns](https://blenderartists.org/u/DavesDesigns)\
**Post date:** [December 11, 2024, 10:57am UTC](https://blenderartists.org/t/shortcut-for-scale-with-0-along-x-y-z-align/1560742/7 "2024-12-11T10:57:08Z")

</div>

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()

---

<div class="post-metadata">

**Author:** ![Okidoki](https://blenderartists.org/user_avatar/blenderartists.org/okidoki/32/1434104_2.png) [@Okidoki](https://blenderartists.org/u/Okidoki)\
**Post date:** [December 11, 2024, 1:15pm UTC](https://blenderartists.org/t/shortcut-for-scale-with-0-along-x-y-z-align/1560742/8 "2024-12-11T13:15:34Z")

</div>

### 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 😉 _(copied from the previous history version enabled in raw format )_ :

`YouNameit.py` _( AxisScaleShortCut.py ?? )_

```auto
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:

```auto
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 😅 )_

For _extension_ this had changed..
