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

    Add Title Items (not packable) to Custom Menu

    General Talk
    programming
    2
    4
    751
    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.
    • G
      Gemini
      last edited by

      Hey Forum,

      I have two questions for you. 😉

      1. Is there a way to add not pickable items like a title written with capital letter to custom menus created by python.
      2. How a toggle line be added and how can be get its sate ?
        I added a part of my code above where the str item is not working sadly.

      THanks,
      G

      ...

      def insert(root: c4d.BaseContainer, title: str, data: MenuData) -> c4d.BaseContainer:
          """Inserts #data recursively under #root under the entry #title.
          """
          # Create a new container and set its title.
          subMenu: c4d.BaseContainer = c4d.BaseContainer()
          subMenu.InsData(c4d.MENURESOURCE_SUBTITLE, title)
      
          # Iterate over the values in data, insert commands, and recurse for dictionaries.
          for key, value in data.items():
              if isinstance(value, dict):
                  subMenu = insert(subMenu, key, value)
              elif isinstance(value, int):
                  subMenu.InsData(c4d.MENURESOURCE_COMMAND, f"PLUGIN_CMD_{value}")
              elif value is None:  # Insert a separator
                  subMenu.InsData(c4d.MENURESOURCE_SEPARATOR, None)
              elif isinstance(value, str):
                  # Add a non-clickable title
                  subMenu.InsData(c4d.MENURESOURCE_STRING, value)
                  
          root.InsData(c4d.MENURESOURCE_SUBMENU, subMenu)
      
          return root
      
      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @Gemini
        last edited by ferdinand

        Hey @Gemini,

        Thank you for reaching out to us. I am struggling a bit with understanding all details of your question(s). Please also note that we do not allow for multi question topics, see Support Procedures: How to ask Questions for details.

        Is there a way to add not pickable items like a title written with capital letter to custom menus created by python.

        I assume you are talking about sub-titles in menus here, @i_mazlov has shown here how to do that.

        How a toggle line be added and how can be get its sate?

        I assume you mean here a menu entry with a checkbox/checkmark next to it? Menus allow you to mark entries as checked or disabled with the label suffixes 'c' and 'd'. E.g.: "I am a checked label&c&" and "I am a disabled label&d&". See ShowPopupDialog() for an example. But one usually does this on a popup menu or dialog menu level.

        The code you show us as "yours", is code I have written in the context of the main menu of Cinema 4D. So, the question is: Do you want to inject things into the main menu of Cinema 4D, or are you just populating a dialog or popup menu.

        I am not sure if you are allowed to place checkmarks there and manually disable menu entries, as Cinema 4D itself owns its main menu. It might ignore such markup there, you would have to try yourself.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        G 1 Reply Last reply Reply Quote 0
        • G
          Gemini @ferdinand
          last edited by

          Hi, thanks for your answer. I'd like to add a title line like here for example the 'DINAMICS' line.
          G

          d7064b20-2060-4305-af64-94bb8f84ad00-image.png

          1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand
            last edited by ferdinand

            Well, my answer answers that, check out the posting I linked to. You must insert a MENURESOURCE_SUBTITLE:

            menu.InsData(c4d.MENURESOURCE_SUBTITLE, "My Heading")
            

            MAXON SDK Specialist
            developers.maxon.net

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