Capture specific view to TIF file on macOS

Hello,
I need to capture from code a specific viewport (even if this viewport is currently hidden), on Rhino for macOS.
I have tried many ways so far, but none of them seemed to work.

1 - RhinoCommon API ViewCapture.CaptureToBitmap()

Although this works like a charm on Rhino for Windows, I have issues exporting the correct viewport on Mac.

I don’t know if the problem is related to setting the correct ActiveViewport PRIOR to capturing the scene, but what I obtain is only and always the current active viewport.
What I do on Windows is:

//Create a temporary view for the capture
var view = m_doc.Views.Add("bbview", DefinedViewportProjection.Top, new Rectangle(new System.Drawing.Point(0, 0), size), true);

//Setting the size again will snug up the camera.
view.Size = size;

view.ActiveViewport.ZoomBoundingBox(viewBounds);

// 600dpi to dot per mm
var dpmm = 600.0 / 25.4;

var captureWidth = (int)(width / scale * dpmm);
var captureHeight = (int)(height / scale * dpmm);
      
// This performs the actual job (the result can either be a capture bitmap or the result of a scripted command).
var viewCapture = new ViewCapture() {
   DrawAxes = false,
   DrawGrid = false,
   DrawGridAxes = false,
   TransparentBackground = true,
   Width = captureWidth,
   Height = captureHeight
};
              
var bmp = viewCapture.CaptureToBitmap(view);
      
//close the temp view
view.Close();

If I do the same on Mac, the captured image is not taken from the “top” view, but rather from the current one (e.g. perspective).

2 - Scripted -_ViewCapture command

I also tried the scripted version.
To try to mimic the above code, I was doing something like:

// Change the current active viewport to the one I want.
var viewportChanged = RhinoApp.RunScript("-_SetActiveViewport Top", echo: true);

// Capture...
var captured = RhinoApp.RunScript("-_ViewCaptureToFile ... <some options>", echo: true);

But the captured boolean result is always false and the view is not captured.
Any idea?

3 - Scripted -_Print

I managed to export a given view with “Rhino PDF" printer, with the exact layout I want.
The problem is that I need a *.tif file as a result, rather than a PDF.

I can provide as printer name ”Image File (PNG, BMP, TIF, …)” and set the other options, but when I send the final Go option to specify the target filename, Rhino shows the following dialog:

I don’t know what else I can try.
Is there any workaround that possibly comes to your mind?

Thank you.

1 Like