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

    Draw Methods doesn't work on GeUserArea

    Cinema 4D SDK
    r21 python
    3
    5
    415
    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.
    • B
      bentraje
      last edited by

      Hi,

      I'm trying to attach a simple GeUserArea with just a bunch of Draw Methods (i.e. DrawText etc) but it appears blank when I execute the script. There are also no errors on the console.

      You can check the wip code here:

      import c4d
      from c4d import bitmaps, documents, gui, plugins, threading, utils
      
      class UserArea(c4d.gui.GeUserArea):
          color = c4d.Vector(1, 0, 0)
      
          def DrawMsg(self, x1, y1, x2, y2, msg):
              self.DrawText("Test Text Area", 10, 10)
              self.DrawSetPen(self.color)
              self.DrawRectangle(x1, y1, x2, y2)
      
              return super(UserArea, self).Message(msg, result)
              return True
      
      
      class MyDialog(c4d.gui.GeDialog):
          def CreateLayout(self):
      
              paramid = 10002
      
              self.AddUserArea(paramid, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 100, 100)
              self.AttachUserArea(UserArea(), paramid)
      
              return True
      
          def Command(self, id, msg):
              return True
      
          def CoreMessage(self, id, data):
              return True
      
      if __name__ == "__main__":
          dlg = MyDialog()
          dlg.Open(dlgtype=c4d.DLG_TYPE_MODAL_RESIZEABLE)
      

      Thank you for looking at my problem

      1 Reply Last reply Reply Quote 0
      • P
        PluginStudent
        last edited by

        The user area has to be a member variable of the GeDialog class:

        class ExampleDialog(c4d.gui.GeDialog):
            # The GeUserArea need to be stored somewhere, we will need this instance to be attached to the current Layout
            geUserArea = ExampleGeUserArea()
        

        See geuserarea_basic_r13.py.

        1 Reply Last reply Reply Quote 1
        • B
          bentraje
          last edited by

          @PluginStudent

          Thanks for the response.
          The DrawSetPen and DrawRectangle works but for some reason the
          DrawGetTextWidth() doesn't.

          I also used the value from the DrawGetTextWidth() but I still get the same result (i.e. the Text is not being drawn)

          Here is the code so far:

          import c4d
          from c4d import bitmaps, documents, gui, plugins, threading, utils
          
          class UserArea(c4d.gui.GeUserArea):
              color = c4d.Vector(1, 0, 0)
          
              def DrawMsg(self, x1, y1, x2, y2, msg):
                  self.DrawText("Test Text Area", 67, 67)
                  print self.DrawGetTextWidth("Test Text Area")
                  #self.DrawSetPen(self.color)
                  self.DrawRectangle(x1, y1, x2, y2)
          
          
          class MyDialog(c4d.gui.GeDialog):
              
              ua = UserArea()
              def CreateLayout(self):
          
                  paramid = 10002
          
                  self.AddUserArea(paramid, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 200, 200)
                  self.AttachUserArea(self.ua, paramid)
          
                  return True
          
              def Command(self, id, msg):
                  return True
          
              def CoreMessage(self, id, data):
                  return True
          
          if __name__ == "__main__":
              dlg = MyDialog()
              dlg.Open(dlgtype=c4d.DLG_TYPE_MODAL_RESIZEABLE)
          
          1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand
            last edited by

            Hi,

            I haven't run your script, but you invoke DrawRectangle after DrawText, covering up any text you have drawn previously.

            Cheers,
            zipit

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 1
            • B
              bentraje
              last edited by

              @zipit

              Thanks for pointing it out. It now works as expected.

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