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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Fill GeDialog combo box dynamically ?

    Scheduled Pinned Locked Moved PYTHON Development
    6 Posts 0 Posters 591 Views
    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.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 12/12/2012 at 09:42, xxxxxxxx wrote:

      INFO : C4d r14, Windows Vista 64, Python

      hm,

      sorry it is me again 🙂 Is it possible possible to fill a GeDialog ComboBox dynamically with
      children / entries after the execution of GeDialog.CreateLayout() ? I have got the 
      following :

          # dialogContainer is a BaseContainer containg the current dialog settings
          # self.Presets is a BaseContainer containing several Bc of the same structure
          # cHelp is a namespace to some c4d related methods. the whole chain is called
          # from GeDialog.Command() :
          #
          # the bc is saved to file ...
          # --------------------------------------------------------------------------------------------------------------	
          def savePreset(self, dialogContainer) :
              presetName = c4d.gui.InputDialog('Preset name:','myPreset {0}'.format(len(self.Presets)))
              dialogContainer.SetString(1000, presetName)
              self.Presets.SetContainer(1000 + len(self.Presets), dialogContainer)
              result = cHelp.SaveHyperFile(self.Presets, self.PresetFilePath, self.HyperKey, True)
              if(result) :
                  self.fillComboBox()
                  print self.SetLong(srCon.IDC_PRESET_COMBOBOX, len(self.Presets))
              return result
          
          # and loaded back here. the ccombox is populated with the new preset names
          # --------------------------------------------------------------------------------------------------------------	
          def fillComboBox(self) :
              result = cHelp.ReadHyperFile(self.PresetFilePath, self.HyperKey, True)
      	if(type(result) == c4d.BaseContainer) :
      		self.Presets = result
              	self.FreeChildren(srCon.IDC_PRESET_COMBOBOX)
              	counter = 0
              	for item in self.Presets:
      	    		# here i am adding the children, and trying to tell c4d that something had changed.
      	    		# had the flush and changed thingie on a higher level first, but then moved them here 
                  		# to be ultrasafe.
                  		self.LayoutFlushGroup(srCon.IDC_PRESET_COMBOBOX)
                  		self.AddChild(srCon.IDC_PRESET_COMBOBOX , counter, item[1].GetString(1000))
                  		self.LayoutChanged(srCon.IDC_PRESET_COMBOBOX)
      		return True
      	else:
      		return False
        
      
      

      I am feeling pretty lazzy for just asking again, but i am not sure what is going wrong there.
      When i execute the plugin, everything works as expected. I save the dialog settings to a
      hyper file and load the content back from the hyperfile. The combobox is also populated as
      expected with my preset names, BUT i cannot visually select anything except the first child.
      Programmatically i can set the combobox to any value i want and is also accepted and
      returned correctly (but also not reflected in the gui).

      thanks for your help, as always.

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 13/12/2012 at 02:54, xxxxxxxx wrote:

        Have you tried removing the calls to LayoutFlushGroup() and LayoutChanged()?

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 13/12/2012 at 04:41, xxxxxxxx wrote:

          Originally posted by xxxxxxxx

          Have you tried removing the calls to LayoutFlushGroup() and LayoutChanged()?

          do you mean this in in a special context ? because i am calling both in my fillComboBox() 
          loop for each preset found and added, as shown in the snippet. also i am not quite
          sure if i am qusing them both correctly. do they actually expect a group ? i am just
          passing the ComboBox.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 13/12/2012 at 05:39, xxxxxxxx wrote:

            Originally posted by xxxxxxxx

            # and loaded back here. the ccombox is populated with the new preset names
                # --------------------------------------------------------------------------------------------------------------
                def fillComboBox(self) :
                    result = cHelp.ReadHyperFile(self.PresetFilePath, self.HyperKey, True)
            if(type(result) == c4d.BaseContainer) :
            self.Presets = result
                    self.FreeChildren(srCon.IDC_PRESET_COMBOBOX)
                    counter = 0
                    for item in self.Presets:
                # here i am adding the children, and trying to tell c4d that something had changed.
                # had the flush and changed thingie on a higher level first, but then moved them here 
                        # to be ultrasafe.
                        self.LayoutFlushGroup(srCon.IDC_PRESET_COMBOBOX)
                        self.AddChild(srCon.IDC_PRESET_COMBOBOX , counter, item[1].GetString(1000))
                        self.LayoutChanged(srCon.IDC_PRESET_COMBOBOX)
            return True
            else:
            return False

            It seems you return True from inside the loop. This is maybe why you can only select the first child.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 13/12/2012 at 05:52, xxxxxxxx wrote:

              sorry about that, that is just a typo I introduced, because the copy/paste messed up 
              the indentions (if the true would be there the combobox wouldn always just contain
              one element , but i have all elements, but i can just select the first).

              before :

              selection:

              after :

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 13/12/2012 at 06:51, xxxxxxxx wrote:

                lol stupid me, if forgot to increase my counter variable and therefor all entries have the same
                ID 🙂

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