EnhanceMainMenu Inconsistent results in different c4d versions
-
Hi,
My plug- in is displayed in the window, but the results are different in different versions. The c4d version before S22 is arranged at the end of the window, and the version 2023 is arranged before. The code has not changed.pic
code:
def EnhanceMainMenu(): mainMenu = gui.GetMenuResource("M_VIEW_WINDOW") pluginsMenu = gui.SearchPluginMenuResource() menu = c4d.BaseContainer() menu.InsData(c4d.MENURESOURCE_SUBTITLE, "Doodle") # Set the name of the menu menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1060253") #switch doodle menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1022257") #draw pen menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1022286") #eraser pen menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1022215") #Add empty frame menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1060256") # active doodle layer menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1060254") #before onion menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1060255") #after onion menu.InsData(c4d.MENURESOURCE_SEPERATOR, True); menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1022384") #duplicate doodle menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1022281") #clear doodle menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1022280") #remove doodle menu.InsData(c4d.MENURESOURCE_SEPERATOR, True); menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1060257") #add doodle layer menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1060258") #top doodle layer if pluginsMenu: # Insert menu after 'Plugins' menu mainMenu.InsDataAfter(c4d.MENURESOURCE_STRING, menu, pluginsMenu) else: # Insert menu after the last existing menu ('Plugins' menu was not found) mainMenu.InsData(c4d.MENURESOURCE_STRING, menu)
Thanks for any help!
-
Hi @chuanzhen,
Thank you for reaching out to us. The gui.SearchPluginMenuResource() function is searching for the category in the M_EDITOR menu. When working with any other menu (e.g. M_VIEW_WINDOW in your exact case), it doesn't make any sense trying to insert custom menu after it (because it points out to a category in a completely different menu).
Hence the following code will be giving consistent results in both S22 and R2023:
def EnhanceMainMenu(): mainMenu = gui.GetMenuResource("M_VIEW_WINDOW") menu = c4d.BaseContainer() menu.InsData(c4d.MENURESOURCE_SUBTITLE, "Doodle") # Set the name of the menu menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1060253") #switch doodle menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1022257") #draw pen menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1022286") #eraser pen menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1022215") #Add empty frame menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1060256") # active doodle layer menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1060254") #before onion menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1060255") #after onion menu.InsData(c4d.MENURESOURCE_SEPERATOR, True); menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1022384") #duplicate doodle menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1022281") #clear doodle menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1022280") #remove doodle menu.InsData(c4d.MENURESOURCE_SEPERATOR, True); menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1060257") #add doodle layer menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1060258") #top doodle layer mainMenu.InsData(c4d.MENURESOURCE_STRING, menu)
Cheers,
Ilia -
@i_mazlov Thanks