0

I set a blender shortcut for a custom operator in my addon using the code described here: Create keyboard shortcut for an operator using python?

When I install the addon the shortcut is registered and works fine. But when I close and reopen blender the shortcut has disappeared from the keymap in edit > preferences. However, the addon is still activated. When I deactivate and reactivate the addon the shortcut reappears and it works. How do I make the shortcut stay?

I tried using the code in the link above instead of my own code as a test and the same problem occurs.

shreya6064
  • 51
  • 2
  • Do you have auto-save set for preferences? Otherwise, you have to also save your preferences in python, or the shortcut won't appear. – Marty Fouts Oct 04 '21 at 13:48
  • Yes I have auto-save enabled. It works fine when I first install the addon and then stops working when I reopen blender. I also tried enabling auto-save within the python script but that did not work. – shreya6064 Oct 04 '21 at 15:52
  • I suppose you could force the preference save with bpy.ops.wm.save_userpref() If that doesn't work, then perhaps the code you're using is broken, although it looks OK to me at a first glance. – Marty Fouts Oct 04 '21 at 15:59

0 Answers0