Title in dropdown menu
-
I found in this topic a code which creates a menu and sub menu but I did not found how to create titles inside menus. something like this:
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()
-
Hello @manudin!
Welcome to the Maxon developers forum and its community, it is great to have you with us!
Getting Started
Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules.
- Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment.
- Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support.
- Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads.
It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: Asking Questions.
About your First Question
These static text separators are just normal separators with provided title. You can do this by assigning BaseContainer instead of boolean (please check the code snippet below).
Cheers,
Iliaimport c4d from c4d import gui def EnhanceMainMenu(): 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_SEPARATOR, True); menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Osphere)) m = c4d.BaseContainer() m.InsData(c4d.MENURESOURCE_SUBTITLE, "My Category") menu.InsData(c4d.MENURESOURCE_SEPARATOR, m) menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Oplane)) mainMenu = gui.GetMenuResource("M_EDITOR") mainMenu.InsData(c4d.MENURESOURCE_STRING, menu) if c4d.threading.GeIsMainThreadAndNoDrawThread(): c4d.gui.UpdateMenus() if __name__ == "__main__": EnhanceMainMenu()