How do I return a list of names and ids for a drop down menu?
-
I'm trying to automatically set a parameter on a shader. The parameter is a dropdown menu (combo box). The items in the drop down are dynamic so I can't just use a static number to set the parameter.
I'm wondering if there's a way to read the names of the items and select the one I want based on the name?
Something like:
items = getComboBoxItems(c4d.SUBSTANCESHADER_CHANNEL) for item in items: if "roughness" in item.name: SubstanceShader[c4d.SUBSTANCESHADER_CHANNEL] = item.id -
found a solution:
substance_shader = diffuse_shader.GetClone() mat.InsertShader(substance_shader) mat[c4d.OCT_MATERIAL_ROUGHNESS_LINK] = substance_shader desc = substance_shader.GetDescription(c4d.DESCFLAGS_DESC_NONE) parm_desc = desc.GetParameter(c4d.SUBSTANCESHADER_CHANNEL) cycle = parm_desc[c4d.DESC_CYCLE] for index, value in cycle: if "roughness" in value.lower(): substance_shader[c4d.SUBSTANCESHADER_CHANNEL] = index break -
Hey @lionlion44,
yes, that is the correct answer. The subject comes up from time to time, here is an answer of mine which is about the very case of yours - discovering substance channels.
Cheers,
Ferdinand