Viewport frame/legend/watermark export error


I’m trying to display preview meshes relating to structural engineering quantities in the Rhino viewport.
Also, I’m trying to display a corresponding legend in the same viewport.

Rhino.Display.DisplayPipeline.PreDrawObjects for the meshes
Rhino.Display.DisplayPipeline.DrawForeground for the legend
I get pretty convincing results. So far so good (here a little screenshot of a suspension bridge with stresses displayed as meshes, and a little summary legend at the bottom):

The issues arise when I want to export the viewport somehow. For instance, when using
ViewCaptureToFile or ViewCaptureToClipboard,
the legend (as well as the Rhino coordinate system) is shrunk and duplicated:

Even worse, when I use “_Print” to export as pdf, my legend gets shrunk and tiled all over the drawing numerous times:

Is there a way around this? I tried to prevent the DrawForeground event from getting called numerous times when Rhino is InCommand. This helped with ViewCaptureToFile as I found out the event gets raised exactly twice, but when printing, the number of times it is raised depends on the clicks the user makes in the print dialog.

Is there a better/best practice for displaying legends/frames/watermarks in a viewport or print? As the information changes all the time (for example when the user display other attributes than stresses), creating a proper 2d-layout with a header of Rhino geometry/text objects is not really an option.

Thanks a lot,


I believe ViewCapture routines set the “IsPrinting” property to true on the display pipeline for when they are being run. IsPrinting==true is the only time that you’ll see the tiling occur in Rhino. When tiling is occurring, you can look at the Viewport’s screen port to help decide when to draw the legend. I don’t really have a great idea for doing this right now with respect to drawing the 2d legend across the tiles, sorry.