Well now, this seems a whole lot more active than the official Blender forums, so I think I’ll post questions here from now on.
Okay, based on the post here, along with some digging, I have come up with the following simple function:
def intuitive_delete(): mode = bpy.context.tool_settings.mesh_select_mode if mode == True: #Vertex select mode, delete selected vertices: bpy.ops.mesh.delete(type='VERT') elif mode == True: #Edge select mode, delete selected edges: bpy.ops.mesh.delete(type='EGDE') elif mode == True: #Face select mode, delete selected faces: #TODO: Customize face delete type! #delType = 'ONLY_FACE' delType = 'FACE' bpy.ops.mesh.delete(type=delType) #Blender leaves the 'nothing' selected, so fix that: bpy.ops.mesh.select_all(action='DESELECT')
Now, I want to make it so the ‘delete’ key runs that. Just… runs it. I don’t need it to have a UI button. I don’t need it to be an official add-on yet. I don’t need it to be a command that the hotkey interface will automagically know how to work with. I just need it to unquestioningly call that function.
I know it’s feasible, because if I paste that into the Python console, it works; the function is registered, and running intuitive_delete() will do what I want. But I need some way to, A) Auto-register that function at runtime, and B) Link the ‘delete’ key to intuitive_delete(). It seems very simple, but… apparently not. Which, naturally, is why I’m here asking for help.