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

    GeDialog in a Python Script does not work

    Cinema 4D SDK
    r20 python
    2
    3
    710
    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.
    • fwilleke80F
      fwilleke80
      last edited by fwilleke80

      Hello,

      I'm probably missing something here, but I can't get a GeDialog in a Python Script (not plugin!) to work at all.

      import c4d
      
      class TestDialog(c4d.gui.GeDialog):
      
          BUTTON_ID = 1001
      
          def CreateLayout(self):
              self.SetTitle("A meaningful dialog title")
              self.AddButton(self.BUTTON_ID, c4d.BFH_SCALE|c4d.BFV_SCALE, 100, 25, "Close Dialog")
              #self.AddDlgGroup(c4d.DLG_OK|c4d.DLG_CANCEL)
              return True
      
          def Message(self, msg, result):
              return True
      
          def Command(self, id, msg):
              if id==self.BUTTON_ID:
                self.Close()
              return True
      
      # Main function
      def main():
          # Test dialog
          diag = TestDialog()
          diag.Open(dlgtype=c4d.DLG_TYPE_MODAL, defaultw=400, defaulth=400)
      
      
      # Execute main()
      if __name__=='__main__':
          main()
      

      The only thing that happens when executing this script is that an empty dialog appears (the size is correct, but there is neither a dialog title, nor any gadgets) that can only be closed by force-quitting Cinema.

      • The console does not show any errors or exceptions.
      • I tested the same code in R20 and R19, both with the exact same result.
      • Manually calling diag.CreateLayout() before the diag.Open() call did not change anything.

      What am I doing wrong?

      Cheers,
      Frank

      0_1547547627704_dialogtest.png

      www.frankwilleke.de
      Only asking personal code questions here.

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

        Hi Frank, you actually return True from the Message method while the result of the parent call was expected

        def Message(self, msg, result):
            return c4d.gui.GeDialog.Message(self, msg, result)
        

        For more information please read the documentation about GeDialog.Message.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 3
        • fwilleke80F
          fwilleke80
          last edited by

          Aaah, ok, thanks!

          I browsed a couple of examples here in the forum, and always saw them return True. Should've known better 🙂

          Cheers,
          Frank

          www.frankwilleke.de
          Only asking personal code questions here.

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