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

    Add a combobox userdata using python

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 551 Views
    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.
    • H Offline
      Helper
      last edited by

      On 26/09/2014 at 11:47, xxxxxxxx wrote:

      How can I add a userdata combobox using python?

      Define a long and adding children to it does not work.

                  bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_LONG) # Create default container
                  bc[c4d.DESC_NAME] = "Point" # Rename the entry
                  element1 = node.AddUserData(bc) # Add userdata container
                  node[element1] = 2 # Assign a value
                  
                  #DTYPE_CHILDREN
                  bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_CHILDREN) # Create default container
                  bc[c4d.DESC_NAME] = "Name 01" # Rename the entry
                  element11 = node.AddUserData(bc) # Add userdata container
                  node[element11] = "Name 01" # Assign a value
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 26/09/2014 at 13:45, xxxxxxxx wrote:

        import c4d  
        def main() :  
           
          obj = doc.GetActiveObject()  
          if not obj: return False  
            
          #This code block creates a ComboButton type button gizmo  
          cbgizmo = c4d.GetCustomDataTypeDefault(c4d.DTYPE_LONG)  
          cbgizmo[c4d.DESC_NAME] = "My Combo"  
          cbgizmo[c4d.DESC_CUSTOMGUI] = c4d.CUSTOMGUI_CYCLE  
            
          #Create a list of names and put them into a container      
          names = c4d.BaseContainer()  
          names.SetString(0,"Scott")  
          names.SetString(1,"Jim")  
          names.SetString(2, "Jane")  
          cbgizmo.SetContainer(c4d.DESC_CYCLE, names)  
          
          entries = op.AddUserData(cbgizmo)  
            
          #This sets the ComboButton to the second entry by default("Jim")  
          #Because you might not want the first entry to be the default  
          op[entries] = 1  
                    
          c4d.SendCoreMessage(c4d.COREMSG_CINEMA, c4d.BaseContainer(c4d.COREMSG_CINEMA_FORCE_AM_UPDATE))  
          c4d.EventAdd()  
          
        if __name__=='__main__':  
          main()
        

        -ScottA

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 27/09/2014 at 00:50, xxxxxxxx wrote:

          Great, thank you.

          And I guess, adding or changing the list of names is then just using BaseList2D.SetUserDataContainer().

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 27/09/2014 at 07:31, xxxxxxxx wrote:

            Edit or add things to the "names" BaseContainer() to change the things in the list.
            SetUserDataContainer() updates the UD after you've changed something inside it.

            -ScottA

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