On 15/05/2014 at 16:38, xxxxxxxx wrote:
That's ok if we want to add new menus to the main C4D UI.
But what about adding sub menu's to the existing menus?
I can't get that one to work:
import c4d
import sys,os
from c4d import gui,plugins
#This is a custom method that will insert a new menu into C4D when it starts up
def EnhanceMainMenu() :
#Start off by getting the main menu resource container
mainMenuBc = gui.GetMenuResource("M_EDITOR")
##################################################################
########## Add a new sub menu to the File menu ###################
########## This does not work!! #################################
#The new menu item we want to add under the File menu
new_menu1 = c4d.BaseContainer() #Create a container to hold a new menu information
new_menu1.InsData(c4d.MENURESOURCE_SUBTITLE, "Scott1") #Set the name of the menu
new_menu1.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_5159") #Add command 'Cube' with ID 5159 to the menu
#Get the first tuple in the mainMenuBc. Which is the "File" menu
fileBc = mainMenuBc[1]
#Add the new menu item's container to the File menu's container
fileBc.InsData(c4d.MENURESOURCE_STRING, new_menu1) #<--- Does not work!!
##################################################################
########## Adds a new menu to the C4D UI #######################
########## This works properly as expected #######################
new_menu2 = c4d.BaseContainer() #Create a container to hold a new menu information
new_menu2.InsData(c4d.MENURESOURCE_SUBTITLE, "Scott2") #Set the name of the menu
new_menu2.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_5159") #Add command 'Cube' with ID 5159 to the menu
mainMenuBc.InsData(c4d.MENURESOURCE_STRING, new_menu2) #Add the new container to the main menu's container
def PluginMessage(id, data) :
#This is where we check the build status of the menus. And also inserts any new ones
if id==c4d.C4DPL_BUILDMENU:
EnhanceMainMenu()
return False
-ScottA