On 18/05/2014 at 10:26, xxxxxxxx wrote:
Nobody knows how to do this?
I've been able to add menu items to the "File" menu in memory only (but they don't show up).
Or
Create a complete copy of the File menu. With my added menu items in it.
But I've not been able to change the existing "File" menu.
import c4d, 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() :
#Create some new menu items that we want to add to the File menu
menu = c4d.BaseContainer() #Create a container to hold our new menu information
menu.InsData(c4d.MENURESOURCE_SUBTITLE, "Scott1") #Set the name of the menu
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_5159") #Add the already registered command to the menu
mainMenu = gui.GetMenuResource("M_EDITOR") #Get main menu resource
subBC = mainMenu.GetContainer(1) #Get the container <---I think this is wrong???
for i,v in mainMenu:
names = v.GetString(c4d.MENURESOURCE_SUBTITLE) #The sub menu names(File,Edit,Create,etc...)
if names == "IDS_EDITOR_FILE":
subBC.InsData(c4d.MENURESOURCE_SUBMENU, menu)
#Now re-check all the items in the "File" menu to see if our new item was added
for j,v2 in subBC:
print v2 #<--- The new menu is there in memory <c4d.BaseContainer object at 0x0000000013199618>
#But it does not show up!?
#If I do this it adds a new sub menu in M_EDITOR called "IDS_EDITOR_FILE"
#This is a copy of the "File menu. **Plus my new menu item**
#I don't want to do that...I want to update the existing "File" menu. Not create a copy of it
#How do I do that?
mainMenu.InsData(c4d.MENURESOURCE_STRING, subBC)
def PluginMessage(id, data) :
if id==c4d.C4DPL_BUILDMENU:
EnhanceMainMenu()
return False
-ScottA