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

    Drawing to Multiple Views at Once

    Cinema 4D SDK
    r23 python windows
    3
    5
    620
    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.
    • ?
      A Former User
      last edited by A Former User

      Hello!
      I'm working on a TagData plugin that draws to the active BaseDraw. I don't suspect it's possible because TagData.Draw only accepts one BaseDraw as a parameter, but I was curious if I can draw to multiple views at once from a tag somehow?

      Thank you!

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        Hi,

        The Draw function will be called for each view that are displayed. The BaseDraw parameter will be filled with the correct one. You don't have to do anything specials it's rather the opposite, if you want to draw something on only one view, you need to check what BaseDraw you received as parameter.

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        ? 1 Reply Last reply Reply Quote 0
        • ?
          A Former User @Manuel
          last edited by

          @m_magalhaes Thank you, Manuel.

          1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand
            last edited by ferdinand

            Hi @blastframe,

            I know that your question has been answered, but just for completeness and future readers - here is a small example for how you can pipe drawing operations to different viewports.

            Cheers,
            Ferdinand

            """How to limit drawing operations to certain view ports and cameras.
            """
            
            import c4d
            
            
            def draw(bd):
                """
                """
                # Get the camera attached to the view port that has been passed.
                camera = bd.GetSceneCamera(doc)
            
                # We only want to draw into a camera "MyCamera" attached to a view port.
                # Using the name of the camera is of course a bad method of
                # identification, better would be comparing it against a BaseLink.
                if (isinstance(camera, c4d.CameraObject) and
                        camera.GetName() == "MyCamera"):
                    # Draw a red dot in top left corner of the viewport.
                    bd.SetMatrix_Screen()
                    bd.SetPen(c4d.Vector(1, 0, 0))
                    bd.DrawHandle(vp=c4d.Vector(50, 50, 0),
                                  type=c4d.DRAWHANDLE_BIG,
                                  flags=0)
                # Draw into all view ports that have a camera with right projection.
                elif (isinstance(camera, c4d.CameraObject) and
                      camera[c4d.CAMERA_PROJECTION] == c4d.Pright):
                    # Draw a green dot in top left corner of the viewport.
                    bd.SetMatrix_Screen()
                    bd.SetPen(c4d.Vector(0, 1, 0))
                    bd.DrawHandle(vp=c4d.Vector(50, 50, 0),
                                  type=c4d.DRAWHANDLE_BIG,
                                  flags=0)
                # And finally draw into any view port that is labeled as "Top". This is
                # probably a bit dicey, since we rely on a string here.
                elif bd.GetName() == "Top":
                    # Draw a blue dot in top left corner of the viewport.
                    bd.SetMatrix_Screen()
                    bd.SetPen(c4d.Vector(0, 0, 1))
                    bd.DrawHandle(vp=c4d.Vector(50, 50, 0),
                                  type=c4d.DRAWHANDLE_BIG,
                                  flags=0)
                return True
            
            
            def main(): pass
            

            Giving you something like this:
            fb644b60-db64-4c0f-a585-54a13022996d-image.png

            MAXON SDK Specialist
            developers.maxon.net

            ? 1 Reply Last reply Reply Quote 0
            • ?
              A Former User @ferdinand
              last edited by

              @ferdinand That's very helpful, thank you!

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