I am new to scripting in blender, kinda new to python as well. I followed a tutorial on how to make a custom menu in python, and then add it as an addon in blender. Now I installed it from file and it worked, I enabled it and assigned an hotkey, but unless I run it from the text editor I get this error:
Report: Error Menu "gino" not found. (gino is the bl_idname)
if I run the script from the text editor once, the hotkey start working and I don't receive any errors. How do I fix this so that when I start Blender my addon work with that hotkey?
This is the code:
bl_info = {"name" : "GinoMenu","category" : "3D View","author" : "Edo"}
import bpy
class customMenu(bpy.types.Menu):
bl_label = "G I N O"
bl_idname = "gino"
def draw(self, context):
layout = self.layout
#pie = layout.menu_pie()
layout.operator("mesh.primitive_cube_add")
layout.operator("mesh.primitive_cone_add")
layout.operator("mesh.primitive_circle_add")
return{'None'}
def register():
bpy.utils.register_class(customMenu)
#bpy.ops.wm.call_menu(name = customMenu.bl_idname)
def unregister():
bpy.utils.unregister_class(customMenu)
if __name__ == "__main__":
register()
bpy.types.Menu
docs re naming convention for menus. Something likebl_idname = "MESH_MT_gino"
Would also call the class the sameclass MESH_MT_gino(bpy.types.Menu):
$\endgroup$bpy.types.TEXT_MT_nvim_buffers
(my menu) is registered. Can call it from the console or from a keymap withbpy.ops.wm.call_menu("TEXT_MT_nvim_buffers")
as expected. Just looked again and wouldn't return anything from a menu. (which is same asreturn None
) $\endgroup$