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

    python combobox get current value

    Cinema 4D SDK
    r21 r20 r19 python
    3
    4
    715
    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.
    • O
      OllyFJ
      last edited by Manuel

      Hey, fairly basic question but I'm pretty new to this and struggling to solve it, I'm trying to write a save script in python, I've filled a combo box with a list of directories, I need to access the string of the currently selected value to link to a second combobox to search for the next folder in the chain, how would I go about doing this? in Houdini I have the same tool working using 'self.ui.jobID.currentText() ' is there a similar function in c4d?

       self.AddComboBox(J_NAME, c4d.BFH_SCALEFIT, initw=300, inith=10)
       self.AddChild(J_NAME,0,'______') 
              self.jobs = 'C:/Users/Olly/Downloads/'
              if os.path.isdir(self.jobs):
              
                  # add only directories to list
                  i = 0
                  dirlist = next(os.walk(self.jobs))[1]
                  dirlist.sort()
                  for d in dirlist:
                      
                      if os.path.isdir(self.jobs+d):
                          i += 1                   
                          self.AddChild(J_NAME, i, d)
      

      Thanks!

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

        Hi,

        comboboxes, i.e. LONG resource elements, cannot hold a string in Cinema, they will always be of type integer. You can get the value of a LONG element with GeDialog.GetInt32(ID_MY_LONG). If you want to react to value changes (when x changed, change y), you have to overwrite GeDialog.Command().

        So if you want to store stuff by their string in a combobox and read the value back, you have to use your own hash table for the mapping.

        Cheers
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        O 1 Reply Last reply Reply Quote 1
        • O
          OllyFJ @ferdinand
          last edited by

          @zipit Thanks mate, that's done it!

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by Manuel

            Hello,

            For your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here.

            • Q&A New Functionality.
            • How to Post Questions especially the tagging part.

            I've already done for this thread.

            I can just confirm what @zipit said. Nothing to add 🙂

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

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