Hi,
I am reading the following
hoping there might be some directory browsing UI.
My intention is to allow the user to pick an output directory for some processing.
Cheers
Hi,
I am reading the following
hoping there might be some directory browsing UI.
My intention is to allow the user to pick an output directory for some processing.
Cheers
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
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