Thanks much for the reply, @m_adam. I'm creating a script for a Redshift material using Redshift's native noises, but that's a fantastic tip on c4d.utils.noise.C4DNoise.CreateMenuContainer
. And apologies for missing the post rules -- I'll be more mindful in the future.
Really just looking for a way to clean up the code (and greater understand how the function works).
This is what I came up with:
def CreateUserDataCycle(obj, name, val, entry1, entry2, entry3, entry4, entry5, entry6, parentGroup=None):
if obj is None: return False
bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_LONG)
bc[c4d.DESC_NAME] = name
bc[c4d.DESC_SHORT_NAME] = name
bc[c4d.DESC_DEFAULT] = 1
bc[c4d.DESC_CUSTOMGUI] = c4d.CUSTOMGUI_CYCLE
names = c4d.BaseContainer()
names.SetString(0,entry1)
names.SetString(1,entry2)
names.SetString(2,entry3)
names.SetString(3,entry4)
names.SetString(4,entry5)
names.SetString(5,entry6)
bc.SetContainer(c4d.DESC_CYCLE, names)
if parentGroup is not None:
bc[c4d.DESC_PARENTGROUP] = parentGroup
element = obj.AddUserData(bc)
obj[element] = val
return element
and...
noiseType = CreateUserDataCycle(op,"Noise Type",2,"Type01", "Type02", "Type03", "Type04", "", "",subGroup2)
textureType = CreateUserDataCycle(op, "Texture", 1, "Concrete", "Scratches", "Grunge", "", "", "", subGroup2)
So far it works, though I'm still working on how to manage the number of "entries" so there aren't blank strings: ""
.
Thanks again, your advice pushed me in the right direction.
Eric