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

    Add Filename to GeDialog

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 256 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

      On 26/12/2013 at 18:54, xxxxxxxx wrote:

      Hello everybody,

      sorry for that stupid question, but how can I add a FilenameElement (like UserData/Filename) to a GeDialog. I didn´t find anything in SDK.

      Thanks alot
      rown

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

        On 27/12/2013 at 02:27, xxxxxxxx wrote:

        There is a filename customgui, you can examine it with the ressource editor plugin. You can also use just storage.SaveDialog().

        happy holidays,
        ferdinand

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

          On 03/01/2014 at 13:33, xxxxxxxx wrote:

          Hello littledevil,

          thx for your reply. It was really helpfull.
          Ive solved it in this way:

          import c4d  
          from c4d import gui  
          #Welcome to the world of Python  
            
          class Dlg(gui.GeDialog) :  
            TEXT = 10001  
            SAVE = 10002  
            PATHSTRING = 10003  
            OK = 20001  
            CANCEL = 20002  
            
            def CreateLayout(self) :  
                self.GroupBegin(0, c4d.BFH_SCALEFIT, cols=1)  
                self.AddEditText(self.TEXT, c4d.BFH_LEFT, initw=500)  
                self.GroupEnd()  
                self.GroupBegin(0, c4d.BFH_SCALEFIT, cols=2)  
                self.AddEditText(self.PATHSTRING, c4d.BFH_SCALEFIT)  
                self.AddButton(self.SAVE, c4d.BFH_LEFT, initw=30, name="...")  
                self.GroupEnd()  
                self.GroupBegin(2, c4d.BFH_SCALEFIT, cols=2)  
                self.AddButton(self.OK, flags=c4d.BFH_SCALEFIT, name="OK")  
                self.AddButton(self.CANCEL, flags=c4d.BFH_SCALEFIT, name="CANCEL")  
                self.GroupEnd()  
                return True  
            
            def Command(self, id, msg) :  
                if id == self.SAVE:  
                    path = c4d.storage.SaveDialog(type=c4d.FILESELECTTYPE_ANYTHING, title="Export", force_suffix="txt")  
                    if path is None: file = ""  
                    self.SetString(self.PATHSTRING, path)  
                  
                if id==self.OK:  
                    text = self.GetString(self.TEXT)  
                    path = self.GetString(self.PATHSTRING)  
            
                    file = open(path, "w")  
                    file.write(text)  
                    file.close  
                      
                    self.Close()  
            
                if id==self.CANCEL:  
                    self.Close()   
                  
                return True  
            
          def main() :  
            dlg = Dlg()  
            dlg.Open(c4d.DLG_TYPE_MODAL, xpos=550, ypos= 200, defaultw=300, defaulth=10)  
            c4d.EventAdd()  
            
            
          if __name__=='__main__':  
            main() 
          

          Greetings
          rown

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