Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    How do I return a list of names and ids for a drop down menu?

    Scheduled Pinned Locked Moved Cinema 4D SDK
    windowspython2025
    3 Posts 2 Posters 30 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L Offline
      lionlion44
      last edited by

      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
      
      1 Reply Last reply Reply Quote 0
      • L Offline
        lionlion44
        last edited by

        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
        
        ferdinandF 1 Reply Last reply Reply Quote 0
        • ferdinandF Offline
          ferdinand @lionlion44
          last edited by

          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

          MAXON SDK Specialist
          developers.maxon.net

          1 Reply Last reply Reply Quote 0
          • First post
            Last post