3
$\begingroup$

I'm new to Blender and I'm trying to add a shortcut to "Set Parent To: Object"

I want the shortcut to go to the action directly without the confirmation dialog, but I can't seem to get it working. Since the shortcut is keyed directly to the menu item "Object", logically it should go there directly without the pop up dialog, right? At least I expected it to work that way.

The UI suggests that P is now connected to the Object action, but this is not the case:

Parent

I've removed all other bindings for P just to make sure

$\endgroup$

1 Answer 1

3
$\begingroup$

Preventing that this dialog appears seems not possible at the moment.


But you can define a 'custom operator' and 'create a shortcut' see: Create Shortcuts for Particle Edit Brushes?

For daily work I've converted this into an Add-on, which creates the shortcut automatically:

enter image description here

Install the Add-on via File > User Preferences > Add-ons. Once it's enabled you can press Shift+P for Set Parent to Object and also Shift+Alt+P for Keep Transform operation in Object Mode:

enter image description here

parent_shortcuts.py

bl_info = {
    "name": "Parenting Shortcuts",
    "description": "Parenting Shortcuts",
    "author": "poor",
    "version": (0, 0, 1),
    "blender": (2, 75, 0),
    "location": "3D View",
    "category": "3D View"
}

import bpy

# operators
class SetParentToObject(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.set_parent_object"
    bl_label = "Set Parent to Object"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        bpy.ops.object.parent_set(type="OBJECT")
        return {'FINISHED'}

class SetParentKeepTransform(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.set_parent_keep"
    bl_label = "Set Parent to Object (Keep Transform)"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        bpy.ops.object.parent_set(type="OBJECT", keep_transform=True)
        return {'FINISHED'}


addon_keymaps = []

# register
def register():
    bpy.utils.register_class(SetParentToObject)
    bpy.utils.register_class(SetParentKeepTransform)

    # handle the keymap
    wm = bpy.context.window_manager
    kc = wm.keyconfigs.addon
    if kc:
        km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
        kmi = km.keymap_items.new(SetParentToObject.bl_idname, type='P', value='PRESS', shift=True)
        addon_keymaps.append((km, kmi))
        kmi = km.keymap_items.new(SetParentKeepTransform.bl_idname, type='P', value='PRESS', alt=True, shift=True)
        addon_keymaps.append((km, kmi))

# unregister
def unregister():

    for km, kmi in addon_keymaps:
        km.keymap_items.remove(kmi)
    addon_keymaps.clear()

    bpy.utils.unregister_class(SetParentToObject)
    bpy.utils.unregister_class(SetParentKeepTransform)


if __name__ == "__main__":
    register()   
$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .