1
$\begingroup$

CASE: Prior to reinstalling Blender I exported a Keymaps.py containing my favorite keymaps. After importing the keymaps in vanilla Blender, I ended up with a ton of redundant keymaps belonging to add-ons that I no longer plan to use.

QUESTION: Is there a method to get rid of keymaps for operators that doesn't exist anymore?

$\endgroup$

1 Answer 1

1
$\begingroup$

You can use Python to do that.

import bpy

for  keymap in bpy.context.window_manager.keyconfigs.user.keymaps:
    for item in keymap.keymap_items:
        if "." in item.idname:
            category, op_name = item.idname.split(".")
            if category in dir(bpy.ops):
                if eval("'" + op_name + "' not in dir(bpy.ops." + category + ")"):
                    print("Removing: " + item.idname)
                    keymap.keymap_items.remove(item)
            else:
                print("Removing: " + item.idname)
                keymap.keymap_items.remove(item)
print("Done.")
$\endgroup$

You must log in to answer this question.

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