On 24/08/2017 at 06:18, xxxxxxxx wrote:
Hi Pim,
yes indeed, if you want to work with Descriptions in Python it will be much easier from R18 on.
Actually I'm not sure you will be able to dynamically fill a Cycle/Combo box in Python with versions previous R18, as you are lacking the ability to overwrite GetDDescription(). the only real option I see is to do it via Cycle in User Data. See this thread: Adding cycles to a UserData Field
For everybody working with R18 and later, it's quite easy and roughly looks like this:
def GetDDescription(self, node, description, flags) :
# Before adding dynamic parameters, load the parameters from the description resource
if not description.LoadDescription(node.GetType()) :
return False
# Get description single ID
singleID = description.GetSingleDescID()
myCycleID = c4d.DescID(nw1) # using ID from above post
if singleID is None or myCycleID.IsPartOf(singleID)[0]:
# Add dynamic parameter
bcCycle = c4d.GetCustomDataTypeDefault(c4d.DTYPE_LONG)
bcCycle.SetInt32(c4d.DESC_CUSTOMGUI, c4d.CUSTOMGUI_CYCLE)
bcCycle.SetString(c4d.DESC_NAME, "Cycle")
# Cycle elements get filled into another container
items = c4d.BaseContainer()
items.SetString(0, "Item 0")
items.SetString(1, "Item 1")
items.SetString(2, "Item 2")
bcCycle.SetContainer(c4d.DESC_CYCLE, items)
# Add cycle to the parameters in specified group
if not description.SetParameter(myCycleID, bcCycle, c4d.DescLevel(SWITCHFRAMEGROUP)) # group ID from above post
return False
# ...
# After parameters have been loaded and added successfully, return True and DESCFLAGS_DESC_LOADED with the input flags
return (True, flags | c4d.DESCFLAGS_DESC_LOADED)