On 08/06/2015 at 00:17, xxxxxxxx wrote:
Hello, as a beginner of C4D Python Scripting, I'm trying to find out how to populate & dynamically a userdata (dropdown - cycle ). When user add new object/spline under specific Null - I want it automatically be added to dropdown userdata. (I'm going to use it as a Python Node in my Xpresso Setup )
Here is my non-working terrible code;
What I want is;
Search null (Profiles) - Get its children names
Populate Userdata as Dropdown (Userdata is located in "Options" null) like 01;Profile1 02;Profile2 03;Profile3
http://www.dropbox.com/s/9f5mwlosm6oy39v/modify_userdata.c4d?dl=0
:cry:
import c4d
from c4d import gui
from c4d import documents
def GetChildren(node) :
global names
options = doc.SearchObject("Options") # This is where userdata located
profiles = doc.SearchObject("Profiles") # Get names of children from this null
userdata = options.GetUserDataContainer() #The master UD container
if options is None:
print "main controls not found"
return
count = len(profiles.GetChildren())
if (node.GetChildren() != []) :
for child in node.GetChildren() :
GetChildren(child)
names = []
names = child.GetName()
print names
print count
nextID = len(options.GetUserDataContainer()) - 1
bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_STRING)
cc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_STRING)
bc[c4d.DESC_NAME] = 'Profiles'
bc[c4d.DESC_CUSTOMGUI] = c4d.CUSTOMGUI_CYCLE
#CUSTOMGUI_STRINGMULTI
options.SetUserDataContainer([c4d.ID_USERDATA, 1], bc)
def main() :
GetChildren(Object)