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()
if parentGroup is not None:
bc[c4d.DESC_PARENTGROUP] = parentGroup
element = obj.AddUserData(bc)
obj[element] = val
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.