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: error without exception set?

    Cinema 4D SDK
    python r20
    2
    6
    1.1k
    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 again,

      Thanks to Maxime's reply, I am one step further with my dialog in a script.

      This works now:

          def CreateLayout(self):
              self.SetTitle("The dialog of my dreams")
              self.AddDlgGroup(c4d.DLG_OK|c4d.DLG_CANCEL)
              return True
      

      But if I try to add any gadgets myself, like this:

          def CreateLayout(self):
              self.SetTitle("The dialog of my dreams")
      
              self.AddButton(id=1001, flags=c4d.BFH_SCALE|c4d.BFV_SCALE, 100, 25, "A button!")
      
              self.AddDlgGroup(c4d.DLG_OK|c4d.DLG_CANCEL)
              return True
      

      I get an error in the Python console, pointing to the Addbutton() line:
      SystemError: error return without exception set

      Why? And how do I avoid it?

      Thanks again in advance!

      Cheers,
      Frank

      PS: Yes, I do know that dialogs in scripts are not recommended 😉

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

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

        Additional info:

        Funny, I can sneak around that error by simply catching and ignoring it:

            def CreateLayout(self):
                self.SetTitle("The dialog of my dreams")
        
                try:
                    self.AddButton(id=1001, flags=c4d.BFH_SCALE|c4d.BFV_SCALE, 100, 25, "A button!")
                except:
                    pass
        
                self.AddDlgGroup(c4d.DLG_OK|c4d.DLG_CANCEL)
                return True
        

        that way, the dialog seems to work as expected. Even the button appears and seems to work.
        But it makes me shake of fear and disgust, so I'd like to actually fix it.

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

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

          Hi Frank, I would like to point you to How To post a question especially tagging and the Q&A Functionality.

          With that's said, I'm not able to get the same error as you with the code provided but instead, I get SyntaxError:non-keyword arg after keyword arg.
          Which is as the error state and error due to no-named parameter after named parameter. So it give us:

          self.AddButton(1001, c4d.BFH_SCALE|c4d.BFV_SCALE, 100, 25, "A button!")
          

          or

          self.AddButton(id=1001, flags=c4d.BFH_SCALE|c4d.BFV_SCALE, initw=100, inith=25, name="A button!")
          

          If this not solve your issue (since I don't the same error) please provide us your full code if it's possible.
          Cheers,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

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

            Hi Maxime,

            thanks for the reply! I did tag tag the post (R20, Python, Classic API) and did use MD syntax to format the code, didn't I? 😉 Will remember to set a topic as question, sorry, didn't know that one yet.

            Anyway, I changed the line to this:

            self.AddButton(id=self.BUTTON_ID, flags=c4d.BFH_SCALE|c4d.BFV_SCALE, initw=100, inith=25, name="Close Dialog")
            

            The original line with the non-keyword args was my mistake, sorry.

            Anyway, the error remains the same (SystemError:error return without exception set). As soon as I remove the line with the Addbutton() call, the error is gone. I'm stumped.

            Even if I break it down to the simplest form allowed, the error still remains:

            self.AddButton(id=1001, flags=0)
            

            Cheers,
            Frank

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

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

              Here with the following code, it's working nicely on R20.026, Win10.

              import c4d
              
              class TestDialog(c4d.gui.GeDialog):
              
                  BUTTON_ID = 1001
              
                  def CreateLayout(self):
                      self.SetTitle("The dialog of my dreams")
                      self.AddButton(id=self.BUTTON_ID, flags=c4d.BFH_SCALE|c4d.BFV_SCALE, initw=100, inith=25, name="Close Dialog")
                      self.AddDlgGroup(c4d.DLG_OK|c4d.DLG_CANCEL)
                      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()
              

              May I ask your full code?
              Do you use any 3rd party module?
              What's your OS, exact Cinema 4D Version? Find The Cinema 4D version at the bottom of the about windows

              Cheers,
              Maxime.

              MAXON SDK Specialist

              Development Blog, MAXON Registered Developer

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

                Hi Maxime,

                now that's interesting. You code runs perfectly fine. If I copy & paste your dialog code into my script, it still works, though your dialog is seemingly similar to mine. So, I have no idea what fixed it, but it did. Maybe some excess trailing spaces somewhere? Weird... but thank you for doing your magic 😄 If I ever find out what was happening here, I'll post here.

                Cheers,
                Frank

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

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