Hi,
I have an addon that reads some hotkeys. This works fine in 2.79. But throws an error now in Blender 2.8.
Traceback (most recent call last):
File "\keymaptest.py", line 19, in execute
KeyError: 'bpy_prop_collection[key]: key "Blender" not found'
location: <unknown location>:-1
The trouble part is the second line in this block. keymaps_3DV:
wm = bpy.context.window_manager # Blender window manager
keymaps_3DV = wm.keyconfigs['Blender'].keymaps['3D View'] # 3D View hotkeys
circle_keymap = keymaps_3DV.keymap_items['view3d.select_circle'] # Circle select keymap object
main_key = circle_keymap.type # "C" in this case
I couldn’t find any hint in the new API and the change logs about changes regarding my issue. Blender, Blender User and Blender Addon should still be valid, shouldn’t it? Could somebody please point me into the right direction here why it’s not longer found?
Kind regards
Arunderan
The script to test it:
# This script is a simple example for an operator that gets called by a button.
# The button to execute it is in the Properties sidebar of the 3D view, in the View tab.
# The output of the operator gets printed to the console.
# You can't read it in the Info editor.
import bpy
# Our Operator
class XX_OT_print_me(bpy.types.Operator):
"""Print me\nPrint Text to Console"""
bl_idname = "view.print_me"
bl_label = "Print hotkey"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
print("Operator is executing")
wm = bpy.context.window_manager # Blender window manager
keymaps_3DV = wm.keyconfigs['Blender'].keymaps['3D View'] # 3D View hotkeys
circle_keymap = keymaps_3DV.keymap_items['view3d.select_circle'] # Circle select keymap object
main_key = circle_keymap.type # "C" in this case
print(main_key)
return {'FINISHED'}
# Our Panel
class XX_PT_printmepanel(bpy.types.Panel):
bl_label = "Print hotkey"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "View"
def draw(self, context):
layout = self.layout
layout.operator(XX_OT_print_me.bl_idname, text="Print")
# Registering our classes. The classes tuple.
classes = (
XX_OT_print_me,
XX_PT_printmepanel,
)
# ------------------- Register Unregister
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
def unregister():
from bpy.utils import unregister_class
for cls in classes:
unregister_class(cls)
# For scripting only
if __name__ == "__main__":
register()