Solved Drawing to Multiple Views at Once

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!

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

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

@m_magalhaes Thank you, Manuel.

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

@ferdinand That's very helpful, thank you!