1
$\begingroup$

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)

enter image description here

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() 
$\endgroup$
7
  • $\begingroup$ Please see the bpy.types.Menu docs re naming convention for menus. Something like bl_idname = "MESH_MT_gino" Would also call the class the same class MESH_MT_gino(bpy.types.Menu): $\endgroup$
    – batFINGER
    Commented Jan 19, 2020 at 11:42
  • $\begingroup$ @batFINGER thank you for your comment, will do but that shouldn't be what is causing the error, correct? Be patient if it's a lame question, I don't know the subject very well, yet. $\endgroup$
    – Edo81
    Commented Jan 19, 2020 at 11:50
  • $\begingroup$ Could be what is causing the error. Also recommend putting version into info dictionary. Are there any messages printed in system console when blender is starting? $\endgroup$
    – batFINGER
    Commented Jan 19, 2020 at 11:53
  • $\begingroup$ @batFINGER thank you for your time, I tried renaming as you suggested and uninstalling and reinstalling the addon but I still get the same error: Report: Error Menu: "MESH_MT_gino" not found $\endgroup$
    – Edo81
    Commented Jan 19, 2020 at 11:56
  • $\begingroup$ Ok, you mention the addon is enabled, can you add a screenshot of the keymap? I have addons that register menus, eg "TEXT_MT_nvim_buffers". I can see it is registered in the python console by auto completing to see that bpy.types.TEXT_MT_nvim_buffers (my menu) is registered. Can call it from the console or from a keymap with bpy.ops.wm.call_menu("TEXT_MT_nvim_buffers") as expected. Just looked again and wouldn't return anything from a menu. (which is same as return None) $\endgroup$
    – batFINGER
    Commented Jan 19, 2020 at 12:07

1 Answer 1

1
$\begingroup$

for anyone facing the same problem in the future
here is the solution, thanx again to batFINGER for helping me find it.
you need to make sure that you put your blender version in the script's dictionary,
in my example:

bl_info = {
    "name" : "customMenu",
    "category" : "3D View",
    "author" : "Edo",
    "blender" : (2,80,0)
}

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .