Appending a sub-menu under an existing sub-menu in Blender 2.8

by Rick T   Last Updated September 12, 2019 03:15 AM

I can add menus to Blender 2.8 with the python code below but how can I add a sub-menu using python to one of Blenders existing menus? I'm trying to add the rtMyMenu sub-menu under Blenders Add-Curve sub-menu (see red arrow). So it would look like

-Add-
-Curve-
      -rtMyMenu-  -rtMyOperator-

-

import bpy

class OBJECT_OT_myoperator(bpy.types.Operator):
    bl_idname = 'object.myoperator'
    bl_label = 'rtMyOperator'
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        # ...affairs...
        return {'FINISHED'}

class OBJECT_MT_mymenu(bpy.types.Menu):
    bl_idname = 'object.mymenu'
    bl_label = 'rtMyMenu'

    def draw(self, context):
        layout = self.layout
        layout.operator(OBJECT_OT_myoperator.bl_idname)

def menu_func(self, context):
    self.layout.menu(OBJECT_MT_mymenu.bl_idname)

def register():
    bpy.utils.register_class(OBJECT_OT_myoperator)
    bpy.utils.register_class(OBJECT_MT_mymenu)
    bpy.types.VIEW3D_MT_add.append(menu_func)

def unregister():
    bpy.utils.unregister_class(OBJECT_OT_myooperator)
    bpy.utils.unregister_class(OBJECT_MT_mymenu)
    bpy.types.VIEW3D_MT_add.remove(menu_func)

if __name__ == "__main__":
    register()

I tried

bpy.types.VIEW3D_MT_add_curve.append(menu_func)         

and

bpy.types.VIEW3D_MT_add_curve.remove(menu_func)

But that doesn't work.

submenus



Related Questions



How to create a Folder Dialog?

Updated April 04, 2015 21:06 PM

Mesh's material_index is an index into what?

Updated April 17, 2015 20:06 PM


OS cursor location in Blender Windows

Updated March 29, 2015 06:05 AM