Hello everyone!
What is problem can be? when i assign hotkey for menu item inside Mesh context, hotkey doesn’t assigned. If i did it inside Object context it’s working like a sharm
import bpy
from mathutils import Vector
class Bake3dCursorUi(bpy.types.Menu):
# Define the "Bake 3d cursor" menu
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_idname = "bake_3dCursor"
bl_label = "Bake 3D Cursor"
def draw(self, context):
layout = self.layout
obj = context.object
# layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("object.rot_locationx", text = "Apply X axis rotation")
layout.operator("object.rot_locationy", text = "Apply Y axis rotation")
layout.operator("object.rot_locationz", text = "Apply Z axis rotation")
# Register all operators and panels
# Define "Extras" menu
def menu_func(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.separator()
layout.menu("bake_3dCursor", text = "Bake 3D Cursor")
# Register classes
classes = [
Bake3dCursorUi,
RotateXOperator,
RotateYOperator,
RotateZOperator,
]
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
# Add "Extras" menu to the "Object" menu
bpy.types.VIEW3D_MT_edit_mesh.append(menu_func)
def unregister():
bpy.types.VIEW3D_MT_edit_mesh.remove(menu_func)
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
if __name__ == "__main__":
register()