Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# for http://blender.stackexchange.com/questions/61546/how-do-i-turn-off-confirmation-dialogues
bl_info = {
"name": "Suppress popups",
"description": "Suppress delete and parent popup ",
"author": "poor",
"version": (0, 0, 1),
"blender": (2, 75, 0),
"location": "3D View",
"category": "3D View"
}
import bpy
# operators
class RemoveObject(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.remove_object"
bl_label = "Remove the selected Object"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.object.delete()
return {'FINISHED'}
# 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)
bpy.utils.register_class(RemoveObject)
# 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))
kmi = km.keymap_items.new(RemoveObject.bl_idname, type='X', value='PRESS', 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)
bpy.utils.unregister_class(RemoveObject)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.