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

    Directory UI component ?

    Cinema 4D SDK
    2
    2
    382
    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.
    • N
      nicholas_yue
      last edited by m_adam

      Hi,

      I am reading the following

      https://developers.maxon.net/docs/py/2023_2/modules/c4d.gui/GeDialog/index.html?highlight=addeditnumberarrows#GeDialog.AddEditText

      hoping there might be some directory browsing UI.

      My intention is to allow the user to pick an output directory for some processing.

      Cheers

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @nicholas_yue this can be done with the CUSTOMGUI_FILENAME
        Here a complete example

        import c4d
        
        
        class ExampleDialog(c4d.gui.GeDialog):
        
            def CreateLayout(self):
                """
                This Method is called automatically when Cinema 4D Create the Layout (display) of the Dialog.
                """
                settings = c4d.BaseContainer()
                settings[c4d.FILENAME_DIRECTORY] = True
                self.AddCustomGui(1000,
                                  c4d.CUSTOMGUI_FILENAME, "",
                                  c4d.BFH_SCALEFIT | c4d.BFV_CENTER, 0, 0, settings)
                # Creates a Ok and Cancel Button
                self.AddDlgGroup(c4d.DLG_OK | c4d.DLG_CANCEL)
        
                return True
        
            def Command(self, messageId, bc):
                """
                This Method is called automatically when the user clicks on a gadget and/or changes its value this function will be called.
                It is also called when a string menu item is selected.
        
                :param messageId: The ID of the gadget that triggered the event.
                :param bc: The original message container
                :return: False if there was an error, otherwise True.
                """
                # User changed the file path
                if messageId == 1000:
                    print(self.GetFilename(1000))
                
                # User click on Ok button
                if messageId == c4d.DLG_OK:
                    print(self.GetFilename(1000))
                    return True
        
                # User click on Cancel button
                elif messageId == c4d.DLG_CANCEL:
                    print("User Click on Cancel")
        
                    # Close the Dialog
                    self.Close()
                    return True
        
                return True
        
        
        def main():
            # Creates a new instance of the GeDialog
            dlg = ExampleDialog()
        
            # Opens the GeDialog, since it's open it as Modal, it block Cinema 4D
            dlg.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE, defaultw=300, defaulth=50)
        
        
        if __name__ == "__main__":
            main()
        

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

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