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

    Remove the Default CreateContextMenu in TreeViewFunctions?

    Cinema 4D SDK
    r21 python
    2
    3
    346
    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.
    • B
      bentraje
      last edited by

      Hi,

      Upon RMB a TreeView item, you'll get the default Remove and Remove All.
      I want to remove them but I'm having problem doing so.

      Here is the working code so far:

          def CreateContextMenu(self, root, userdata, obj, lColumn, bc):
      
              bc = None # Delete the existing base container
              bc = c4d.BaseContainer() # Create a blank one
              bc.SetString(1231245, "Hello World!") # Add a new entry
      

      Regards,
      Ben

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        Hi,

        As said in the documentation here you have to remove those entry in the basecontainer provided. You can override bc content like this.

        for that you have several option

                # one of those  solution should work
                # 1 - flush the BaseContainer
                bc.FlushAll()
                
                # 2 - Remove data using our API
                bc.RemoveData(c4d.ID_TREEVIEW_CONTEXT_REMOVE)
                bc.RemoveData(c4d.ID_TREEVIEW_CONTEXT_RESET)
                
                # 3- Remove data using Python
                del (bc[c4d.ID_TREEVIEW_CONTEXT_REMOVE])
                del (bc[c4d.ID_TREEVIEW_CONTEXT_RESET])
        

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 2
        • B
          bentraje
          last edited by

          @m_magalhaes

          Thanks! It works as expected

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