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

    GeUserarea crash when Redraw() in Message()

    Cinema 4D SDK
    r20 python
    2
    3
    728
    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.
    • M
      mike
      last edited by

      hi,
      i write a GUI and use mouse left to refresh GeUserarea , mouse right stop refresh. Unfortunately, when click mouser left, it crash. Somebody can tell me what I did wrong ? this is my code.
      Hope your help!

      import c4d
      from c4d import gui
      
      class MyArea(gui.GeUserArea):
          def __init__(self) :
              self.leftclick = False
      
          def GetMinSize(self) :
              return (600, 500)
      
          def DrawMsg(self,x1, y1, x2, y2, msg):
              self.DrawSetPen(  c4d.Vector(.21) )
              self.DrawRectangle(x1, y1, x2, y2)
      
          def Message(self, msg, result):
              if msg.GetId():
                  if self.leftclick:
                      self.Redraw()
              return c4d.gui.GeUserArea.Message(self, msg, result)
          
          def InputEvent(self, msg) :
              if msg[c4d.BFM_INPUT_DEVICE] == c4d.BFM_INPUT_MOUSE:
                  if msg[c4d.BFM_INPUT_CHANNEL] == c4d.BFM_INPUT_MOUSELEFT:
                      self.leftclick = True
                  if msg[c4d.BFM_INPUT_CHANNEL] == c4d.BFM_INPUT_MOUSERIGHT:
                      self.leftclick = False
              return True
      
      class Dialog(gui.GeDialog):
          def __init__(self, area) :
              self.area = area
      
          def CreateLayout(self) :
              self.AddUserArea(10010, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT)
              self.AttachUserArea(self.area, 10010)
              return True
      
      def main():
          area = MyArea()
          MyDialog = Dialog(area)
      
          MyDialog.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE)
      
      if __name__ == "__main__":
          main()
      
      1 Reply Last reply Reply Quote 1
      • M
        m_adam
        last edited by

        Hi @mike you are simply doing an infinite loop since

            def Message(self, msg, result):
                if msg.GetId():
                    if self.leftclick:
                        self.Redraw()
        

        Actually redraw the UI, which result to some Message been sent and you ask again to redraw.
        One way could be to ask for redraw directly in the InputEvent or simply reset the left click status to False before your redraw call.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        M 1 Reply Last reply Reply Quote 3
        • M
          mike @m_adam
          last edited by

          @m_adam oh,i miss this reason,thank you : )

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