0
$\begingroup$

Is there any way to map the sequence of commands "s, x, 0", "s, y, 0", and "s, z, 0" to keys? I use these a lot while modeling, and was hoping to map them to a single button, but can't seem to find any way to do it.

I was able to achieve this in the UV editor using the align commands.

I tried copying the python output of these commands to a custom hot-key, but it didn't work. I'm a programmer, but I don't know much about python. It seemed like the script was too complex for a hot key.

Thanks for any advice, Robert

$\endgroup$
1
$\begingroup$

Save this to a .py file and install it as an addon


import bpy

bl_info = {
    "name": "Scale 0 Operators",
    "author": "Jan Kadeřábek",
    "version": (1, 0),
    "blender": (2, 7, 0),
    "location": "",
    "description": "",
    "category": "User",
}

class scale_x_0(bpy.types.Operator):
    bl_idname = "view3d.scale_x_0"
    bl_label = "Scale X 0"

    def execute(self, context):
        bpy.ops.transform.resize(value=(0, 1, 1))
        return {"FINISHED"}

class scale_y_0(bpy.types.Operator):
    bl_idname = "view3d.scale_y_0"
    bl_label = "Scale Y 0"

    def execute(self, context):
        bpy.ops.transform.resize(value=(1, 0, 1))
        return {"FINISHED"}

class scale_z_0(bpy.types.Operator):
    bl_idname = "view3d.scale_z_0"
    bl_label = "Scale Z 0"

    def execute(self, context):
        bpy.ops.transform.resize(value=(1, 1, 0))
        return {"FINISHED"}


def register():
    bpy.utils.register_class(scale_x_0)
    bpy.utils.register_class(scale_y_0)
    bpy.utils.register_class(scale_z_0)


def unregister():
    bpy.utils.unregister_class(scale_x_0)
    bpy.utils.unregister_class(scale_y_0)
    bpy.utils.unregister_class(scale_z_0)

This will allow you to set a shortcut for each "scale 0" action.

So after enabling the addon, navigate to User Preferences -> Input -> 3D View -> 3D View (Global) and add shorcuts by inserting corresponding operators, i.e. for scale X = 0, enter view3d.scale_x_0:

enter image description here

It should work for UV editor too, just assign the shortcuts again in Input -> Image -> UV Editor.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.