On 24/05/2014 at 08:23, xxxxxxxx wrote:
You can't add things to the "Character Tags" menu because that's being generated from a plugin. And not the menu manager.
The ID for the Bookmarks sub menu is: IDS_SB_BOOKMARKS
But the big problem is how to add new menus to anything but the "File" menu?
I can do it in C++. But I cannot figure out how to do it in Python.
I can't figure out how to update the menu's container after I add my new sub menu to it.
This example plugin attempts to add a new sub menu to the "Create" menu:
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
mainMenu = gui.GetMenuResource("M_EDITOR") #This is a BaseContainer type
#Create some new menu items that we want to add to the "Create" menu
newMenu = c4d.BaseContainer() #Create a container to hold our new menu information
newMenu.InsData(c4d.MENURESOURCE_SUBTITLE, "Scott") #Set the name of the menu
newMenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_5159") #Add the already registered command to the menu
subMenus = mainMenu.GetData(1) #The BaseContainers in the M_EDITOR's container
#First we have to get the "Create" menu somehow
#So I loop through the menus and grab it this way
CreateMenu = None
for i,v in mainMenu:
if v.GetString(c4d.MENURESOURCE_SUBTITLE) == "IDS_MENU_CREATE":
CreateMenu = v
#Now that I have the "Create" menu stored in it's own variable
#I add my new menu to the Create menu by inserting it's container into the "Create" menu's container
#The same way that we add a new menu to the "File" menu (which seems to work fine)
#Now I check the Create menu's container to see if I successfully added the new menu to it
#for i,v in CreateMenu: print v #<---Yes...A new BaseContainer(my new menu) was successfully added to the "Create" menu
#PROBLEM!! The new menu does not show up in the Create menu! :-(
#It's not showing up because I have not updated the "Create" menu's container after I added my new menu to it
#How do I update the "Create" menu's BaseContainer?
#mainMenu.SetData(1, subMenus) #<---WRONG!!!
#mainMenu.SetData(1, CreateMenu) #<---WRONG!!!
#This method adds our new menus dynamically(not just when C4D launches)
def PluginMessage(id, data) :
#This is where we check the build status of the menus. And also inserts any new ones
It's weird how we can only add sub menus to the "File" menus. But not any of the other ones.
I can do it in C++ so we should be able to do it with Python. Unless it's a bug.
It would be really nice if support would answer how to add menus to anything other than the "File" sub menu.