Page MenuHome

Addon's keymaps are not registered at Blender opening if the addon's enable state is saved in user preferences
Closed, DuplicatePublic


Blender Version
Broken: 2.80

Short description of error

The code bellow illustrates the issue, it register a new shortcut (here for example the translate operator on numpad asterix key). When the addon is activated for the first time, then the shortcut works correctly. If this activation state is saved in user preferences and then Blender reopenned, the shortcut does not works anymore.

bl_info = {
	'name': 'Test',
	'blender': (2, 80, 0),
	'category': '3D View'

import bpy

def register():
	wm = bpy.context.window_manager
	kc =
	km = kc.keymaps['3D View']
	kmi ='transform.translate', type='NUMPAD_ASTERIX', value='PRESS')

def unregister():
	wm = bpy.context.window_manager
	km =['3D View']
	kmi = km.keymap_items.remove(km.keymap_items['transform.translate'])

if __name__ == "__main__":