How to get the name of a submenu

Hi, after enabling tooltips I can see the name of the menu (in this case VIEW3D_MT_uv_map). But lets say that I'm creating a new mesh add operator and I don't want to place it in the main Add menu, but in Add -> Mesh (in object mode in this case, not edit mode). Placing the mouse over a sub-menu does not display the name of the submenu. Is there any way to do this? 

Thanks!

1 love
Reply
  • Spencer Magnusson replied

    Great question! So there's a couple ways to problem solve this:

    • For this specific case, you can use "Edit Source" on its parent menu. If you hover over the "Add" menu, right-click it, "Edit Source", and pull up the Python file. Thankfully, the add mesh menu class is defined in there as well. But even if it's not, the Add menu would still need the name for its layout, so it's likely you would still see it.
    • You can search "bpy.types" in the Python terminal. You can use the autocomplete to your advantage and press tab on "bpy.types.VIEW3D_MT_" and peruse the list to find a name. Submenus usually have similar names.
    • You can also search add-ons online that have similar functionality, and see which menu class they reference.
    • Lastly, you could search the source code at projects.blender.org/blender/blender (or its mirror repo on GitHub, which in my opinion has a better search engine). But since this is just for a Python class name, I rarely do this unless I just cannot find anything about it.

    It's not as ideal as with the tooltip on the main menus, but only a few more steps at most.

    2 loves