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

    How to open a GeDialog Modal to default width & height?

    Cinema 4D SDK
    python sdk
    3
    5
    675
    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.
    • ?
      A Former User
      last edited by A Former User

      Hi!
      I have a basic question, but I haven't been able to find an answer on the forums or internet search.

      How do you open an GeDialog to its default width and height? I've tried using integers, 0, and gui.SizePix() (though I believe that is for UI gadgets) with defaultw and defaulth.

      import c4d
      from c4d import gui
      
      class MyDialog(gui.GeDialog):
          def __init__(self):
              pass
      
      def main():
          myDialog = MyDialog()
          myDialog.Open(c4d.DLG_TYPE_MODAL, xpos=-2, ypos=-2, defaultw=528,
              defaulth=228)
      
      if __name__=='__main__':
          main()
      

      My dialog is opening as a square.

      Square.png

      I found this post but it only mentions that DLG_TYPE_ASYNC types cannot have their sizes set.

      How can I open a modal to its default width and height?

      Thank you.

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

        Hi,

        your script works fine for me (I am on Win R20 and get a rectangle shaped dialog). What is your environment?

        Cheers,
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        ? 1 Reply Last reply Reply Quote 0
        • ?
          A Former User @ferdinand
          last edited by A Former User

          @zipit Thank you for checking.

          I'm on a PC, Windows 10, Cinema 4D R21. I experienced this unpredictability in my Command Plugin, so then tried it again with this simple script in the Script Editor to the same results.

          I'm wondering if window size preferences are getting set somehow. It's very bizarre (and frustrating!).

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

            hi,

            this is a knowed bug, please see this thread
            Combined with this thread

            you can end up with this kind of sript

            import c4d
            import os
            from c4d import gui
            
            
            class OptionsDialog(gui.GeDialog):
                
                @staticmethod
                def GetScriptIdByName():
                    """
                    this static function allow you to retrieve the id of the current script.
                    the name, must be the filename, not a custom name.
                    """
                    name = os.path.splitext(os.path.basename(__file__))[0]
                    if name is None:
                        return None
                    pluginList = c4d.plugins.FilterPluginList(c4d.PLUGINTYPE_COMMAND, True)
                    for plugin in pluginList:
                        if plugin.GetName() == name:
                            return plugin.GetID()
                        
                    return None
                
                def CreateLayout(self):
                    self.SetTitle('Dummy Dialog 700x200px')
                    self.AddMultiLineEditText(1000, c4d.BFH_SCALEFIT, inith=50, initw=500, style=c4d.DR_MULTILINE_READONLY)
                    self.SetString(1000, "Hello World!")
                    if self.GroupBegin(1001, c4d.BFH_CENTER, 2, 1):
                        self.AddDlgGroup(c4d.DLG_CANCEL|c4d.DLG_OK)
                    self.GroupEnd()
                    self.ok = False
                    return True
                
                def Command(self, id, msg):
                    if id==c4d.DLG_CANCEL:
                        self.Close()
                        return False
                    elif id==c4d.DLG_OK:
                        self.ok = True
                        self.Close()
                    return True
            
            def main():
                
                
                pluginID = OptionsDialog.GetScriptIdByName()
                if pluginID is None:
                    return
                
                dlg = OptionsDialog()
                dlg.Open(c4d.DLG_TYPE_MODAL, pluginid = pluginID , xpos=-2, ypos=-2, defaultw=700, defaulth=200)
            
            if __name__=='__main__':
                main()
            
            

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            ? 1 Reply Last reply Reply Quote 0
            • ?
              A Former User @Manuel
              last edited by

              @m_magalhaes Thank you for this workaround. I hope to see that bug fixed soon! It seems like one that would affect many scripts & plugins.

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