Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Title in dropdown menu

    Cinema 4D SDK
    python
    2
    2
    740
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      manudin
      last edited by

      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:
      40e5f55b-8b78-440d-9aa1-bf89d20694d9-image.png

      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()
      
      
      i_mazlovI 1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov @manudin
        last edited by

        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,
        Ilia

        import 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()
        

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 2
        • First post
          Last post