I am loosing my mind here.

Every example addon in blender uses bpy.types.INFO_MT_file_export yet not a single doc explains where the hell the name INFO_MT_file_export comes from.

The doc for bpy.types doesn’t have anything about it. Which leads me to believe we are accessing some object.

I can draw the conclusion that it’s a bl_idname for the info menu and the export submenu, but I don’t understand why we can access it using the dot operator inside of bpy.types, or why we can call the append and remove function if it’s a type of Menu.

Moreover, is there a list or something of all of these predefined possible menu ids?


Mousing over the base of a menu gives you the bl_idname.

enter image description here

If you right click and select edit source it will open up the code for that space in the text editor enter image description here

In this file you will find

class INFO_MT_file_export(Menu):
    bl_idname = "INFO_MT_file_export"
    bl_label = "Export"

    def draw(self, context):
        if bpy.app.build_options.collada:
            self.layout.operator("wm.collada_export", text="Collada (Default) (.dae)")
        if bpy.app.build_options.alembic:
            self.layout.operator("wm.alembic_export", text="Alembic (.abc)")

which affirms that it is a Menu class. The naming convention used by blender for operators and menus is <SPACE>_<TYPE>_<name> where in this case it's the INFO space, is menu type MT and named file_export.

When a blender menu (or operator) is registered it becomes known to bpy.types. If the naming convention is followed, we can find all menus in the info space, simply by using auto-complete in the python console.

>>> bpy.types.INFO_MT_

To get a complete list of all menus, you can use python's built-in dir() function:

base_type = bpy.types.Menu
for typename in dir(bpy.types):
    bl_type = getattr(bpy.types, typename)
    if issubclass(bl_type, base_type):
        print (bl_type)
  • $\begingroup$ One last question, how come are we able to use append and remove? Those functions are present in the Menu class, or are they added by the subclass? $\endgroup$ – Evgeny Vasilyev Jun 5 '18 at 13:03
  • $\begingroup$ It's a class method of bpy.types.Menu and maybe not that well documented. Type bpy.types.Menu.append( <ctrl><space> (autocomplete) into py console. $\endgroup$ – batFINGER Jun 5 '18 at 13:16
  • 1
    $\begingroup$ Aka, not documented at all... $\endgroup$ – Evgeny Vasilyev Jun 5 '18 at 14:20
  • 1
    $\begingroup$ Just adding for posterity: Settings->Display->Python Tooltips must be enabled to get the bl_idname to show up when mousing over menus. $\endgroup$ – Bureto Dec 3 '20 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.