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

    Getting a pointer to a UserArea

    Cinema 4D SDK
    python r19 r20
    3
    5
    890
    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.
    • R
      rui_mac
      last edited by

      I have a dialog defined in a res file. My dialog contains three user areas.
      Now I want to be able to deal with them.
      How can I get a variable pointing to each one of the user areas, so that I can create a class for each one?

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

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • S
          s_bach
          last edited by

          Hello,

          in Python, there are no pointers.

          As usual, you have to define a GeUserArea based class to define your user area. Then you just have to attach that class to the user area declared in your resource file using its ID. You can do that with AttachUserArea().

          # custom user area class
          class ResourceUserArea(gui.GeUserArea):
          
              def GetMinSize(self):
                  return 100, 100
          
              def DrawMsg(self, x1, y1, x2, y2, msg_ref):
          
                  self.OffScreenOn()
                  self.SetClippingRegion(x1, y1, x2, y2)
          
                  color = c4d.Vector(1,0,0)
                  self.DrawSetPen(color)
                  self.DrawRectangle(x1, y1, x2, y2)
          
          class ResourceDialog(c4d.gui.GeDialog):
          
              # user area instance
              _resourceUserArea = ResourceUserArea()
          
              def CreateLayout(self):
          
                  # load dialog resource
                  if self.LoadDialogResource(10100, None, 0) == False:
                      return False
          
                  # attach user ara instance to user area defined in resource
                  self.AttachUserArea(self._resourceUserArea, 10103, c4d.USERAREAFLAGS_NONE)
          
                  return True
          

          best wishes,
          Sebastian

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

          R 1 Reply Last reply Reply Quote 2
          • R
            rui_mac @s_bach
            last edited by

            @s_bach said in Getting a pointer to a UserArea:

            AttachUserArea

            Thank you, Sebastian. It worked fine.
            But, when testing it in R14, it tells me that:

            AttributeError: 'module' object has no attribute 'USERAREAFLAGS_NONE'

            So, I replaced the c4d.USERAREAFLAGS_NONE with 0 (zero).
            It will work fine in R14 to R20, right?

            1 Reply Last reply Reply Quote 0
            • S
              s_bach
              last edited by

              Hello,

              I don't have a Cinmea 4D R14 version so I can't test that case.

              But in R20 some symbols have changed. E.g. c4d.DESCFLAGS_SET_0 was changed to c4d.DESCFLAGS_SET_NONE. Similarly, c4d.USERAREAFLAGS_NONE was c4d.USERAREA_0.

              best wishes,
              Sebastian

              MAXON SDK Specialist

              Development Blog, MAXON Registered Developer

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