Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    EnhanceMainMenu Inconsistent results in different c4d versions

    Cinema 4D SDK
    2023 python
    2
    3
    405
    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.
    • chuanzhenC
      chuanzhen
      last edited by

      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
      未标题-1.png

      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!

      相信我,可以的!

      1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov
        last edited by

        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

        MAXON SDK Specialist
        developers.maxon.net

        chuanzhenC 1 Reply Last reply Reply Quote 1
        • chuanzhenC
          chuanzhen @i_mazlov
          last edited by

          @i_mazlov Thanks

          相信我,可以的!

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