Create a ".pyp" file in the Plugins directory(my_menu.pyp) and try this example.
import c4d
from c4d import gui
def EnhanceMainMenu():
mainMenu = gui.GetMenuResource("M_EDITOR")
pluginsMenu = gui.SearchPluginMenuResource()
menu = c4d.BaseContainer()
menu.InsData(c4d.MENURESOURCE_SUBTITLE, "My Menu 1")
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Ocube))
menu.InsData(c4d.MENURESOURCE_SEPERATOR, True);
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Osphere))
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Oplane))
submenu = c4d.BaseContainer()
submenu.InsData(c4d.MENURESOURCE_SUBTITLE, "Menu 2 ")
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Onull))
menu.InsData(c4d.MENURESOURCE_SUBMENU, submenu)
if pluginsMenu: mainMenu.InsDataAfter(c4d.MENURESOURCE_STRING, menu, pluginsMenu)
else: mainMenu.InsData(c4d.MENURESOURCE_STRING, menu)
def PluginMessage(id, data):
if id==c4d.C4DPL_BUILDMENU:
EnhanceMainMenu()