Capture viewport with a different display mode


Can we capture a viewport with a chosen display mode without selecting it in the viewport, like in zbuffer?


@rajaa - can you help with this?

Hi @seg You can pick different view, but you cannot pick different display mode from within the view capture dialog in the command. Is that what you are asking about?

Thanks @rajaa
Yes, but it looks is not available
I use this way:

// Change to lineart display mode 1
view.ActiveViewport.DisplayMode = Rhino.Display.DisplayModeDescription.GetDisplayMode(lineartdisplay);


// Capture lineart image
lineart = view_capture.CaptureToBitmap(view);

// Change to lineart display mode 2
view.ActiveViewport.DisplayMode = Rhino.Display.DisplayModeDescription.GetDisplayMode(segdisplay);


// Capture segmented image
segimage = view_capture.CaptureToBitmap(view);

But like in ZBufferCapture.SetDisplayMode will be better

ZBufferCapture depth = new ZBufferCapture(view.ActiveViewport);
zbuffer = depth.GrayscaleDib();
resultpictureBox.Image = zbuffer;

@jeff can you help?

Hi @rajaa
This code works perfect

 private void RunScript(List<string> displays, bool capture, ref object A)
    var doc = Rhino.RhinoDoc.ActiveDoc;
    var view = doc.Views.ActiveView;
    var currentdisplay = view.ActiveViewport.DisplayMode;
      foreach(var d in displays)
        Capture(view, d, currentdisplay);
    A = images;

  // <Custom additional code> 
  List<Bitmap> images = new List<Bitmap>();
  void Capture(RhinoView view, string display, DisplayModeDescription current)
    Rhino.Display.DisplayModeDescription targetDisplay = Rhino.Display.DisplayModeDescription.FindByName(display);

    if (view == null) return;
    if (targetDisplay == null) return;
    view.ActiveViewport.DisplayMode = targetDisplay;
    Bitmap bitmap = view.CaptureToBitmap(targetDisplay);
    if(bitmap != null)
    view.ActiveViewport.DisplayMode = current;

So is there still a question here? Looks like you’ve got everything working.


Thanks @jeff
If there is a better solution of course i will choose it.

Hi! I have a question regarding the bitmap preview component. Could you please tell me which one you are using?

This is from my plugin Wizzard , but it is not available now in food4rhino until i fix some other components

I see, looks nice (minimalistic and informative). Will try it once available

1 Like