Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Clearing the list of a ComboBox (Dropdown) - Python API

    Cinema 4D SDK
    python
    2
    3
    586
    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.
    • E
      ezeuz
      last edited by

      I want to use dropdown to select an object from a list of children from the targeted object. I managed to populate it just fine, but the issue is, how do you clear it so that I can repopulate the list when a different object is targeted later?

      # Initialize dropdown for each parameter
      for i, param in enumerate(self.params):
        self.AddComboBox(ID_DROPDOWN + i)
      
      # Once a target is selected
      for i in range(len(self.params)):
        for j, child in enumerate(self.children):
          self.AddChild(ID_DROPDOWN + i, j+1, child)
      

      My current idea is to remove the dropdown element entirely, but then I would have a hard time putting the dropdowns back in their respective layout positions like before.

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @ezeuz
        last edited by ferdinand

        Hey @ezeuz,

        thank you for reaching out to us. Dynamic UIs are possible with GeDialog but there is no data model abstraction as you might be accustomed to by newer UIs. So, you have to rebuild your UI by hand. I once showed here how to do something like that while also implementing a very simple data model.

        But for freeing the children of popup buttons and combo boxes, you do not need all that, there you can just call GeDialog.FreeChildren. But just like for the larger level of fully dynamic dialog UIs, it is probably best to write yourself a small abstraction with a property MyComboItems or something like that. Look at my code example I linked to when you are lost on what I mean with that, there I implemented a property Items which in this case populated a list of items, but you could write something similar for your combo box content (and state).

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        E 1 Reply Last reply Reply Quote 1
        • E
          ezeuz @ferdinand
          last edited by

          @ferdinand Thanks a ton again! Yeah that dynamic UI is indeed something that fits perfectly with my current case, and possibly some other features I want to implement. Tho, I will revisit it later once I get to creating an MVP for my plugin. So I will use FreeChildren() for now.

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