RhinoCommon Printing


I’m struggling with a print issue in RhinoCommon and a Display Conduit that honestly has be stumped.

Our display conduit draws some custom OpenGL to the screen. In normal viewports this works fine and prints out correctly.

However when we render into a detail view we start to have problems with printing. I believe I can see where the problem is, I just can not find where in the SDK to get the correct information from.

Below is a snipped of code from our display conduit.

int width = e.Viewport.Size.Width; int height = e.Viewport.Size.Height; int offsetX = 0; int offsetY = 0;

if (e.Viewport.ViewportType.Equals(ViewportType.DetailViewport)) {
offsetX = e.Viewport.Bounds.Left;
offsetY = e.Viewport.ParentView.MainViewport.Bounds.Bottom - e.Viewport.Bounds.Bottom;

Width, height, offsetX and offsetY relate to the OpenGL viewport and therefore where we should render our graphics.

In the normal model views/prints the view naturally fills the whole render window so offsetX and offsetY would be 0. When rendering a detail view the OpenGL viewport needs to be offset to the correct location in the viewport (there could be many detail views on the page).

The code above does this correctly for detail views on a page and it all looks fine. Until we try to print… then it goes horribly wrong.

The offsetX appears to be ok, it’s the offsetY that is not… and the graphics get drawn in the wrong place in the preview window and in a different wrong place when actually printed.

This is because the e.Viewport.ParentView.MainViewport.Bounds is returning the main window size in Rhino, not the print preview paper outline view on the screen… nor the overall view when doing the printing which are clearly different to the Main Viewport… so… where do I find these “bounds” so that I can draw my data correctly into the print preview AND print output?

Many Thanks


And naturally 10 minutes after posting my question I found the answer myself!..

For future reference, this should be used for offsetting the Y value in Detail Views…




This works in both the “live” view and the “print” views.

Problem solved :slight_smile: