3
$\begingroup$

I know that I can extend menus with modifications of:

def menu_draw(self, context):
    self.layout.operator(myOperatorClass.bl_idname)

bpy.types.INFO_MT_file.append(menu_draw)

which would add an item to the File menu. Question is, how do I add items to submenus? For example, how would I add an item to File > Export?

I tried bpy.types.INFO_MT_file.Export.append(menu_draw), it does not work.

$\endgroup$
4
$\begingroup$

You were close!

A good way to find this kind of stuff is to open the source of any of the addons that add themselves to the export submenu. For our purposes you could look at the DXF exporter script.

from the __init__.py file in scripts/addons/io_export_dxf

bpy.types.INFO_MT_file_export.append(menu_func)

This information is available as a template too from:

Text Editor -> Templates -> Python -> Operator File Export

Clicking the menu item will add and show operator_file_export.py in the Text Editor.

$\endgroup$

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.