Add a combobox userdata using python

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

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"  
  #Create a list of names and put them into a container      
  names = c4d.BaseContainer()  
  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))  
if __name__=='__main__':  


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

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.