ViewCapture + displayed lineweights bug


Couple things seemingly wrong with ViewCapture:

  1. When doing a view capture (Rhino.Display.ViewCapture.CaptureToBitmap(view)) the display thickness of curves and edges in certain display modes (Pen) is scaled up if the resolution is larger than the viewport.
    This is different from before, where the line thickness stayed the same no matter the resolution, and allowed us to get finer lines and more detail, especially at larger resolutions: a 1px line stayed 1px no matter what resolution the image was being output as.
    Setting ViewCapture.ScaleScreenItems = False doesn’t seem to have any effect…
    Has there been a change in the way this is handled? Is there a new setting to toggle this?

  2. Also, doing ViewCapture.CaptureToBitmap(ViewCaptureSettings) throws an error in Python, says it’s expecting a RhinoView and got a ViewCaptureSettings. The documentation says CaptureToBitmap can be overloaded with a ViewCaptureSettings object…

Any tips very welcome!

Hi @tom_svilans,

Here is a simple example that might be helpful.

import System
import Rhino
import scriptcontext as sc

def SampleViewCaptureToFile():
    view = sc.doc.Views.ActiveView;
    if view:
        view_capture = Rhino.Display.ViewCapture()
        view_capture.Width = view.ActiveViewport.Size.Width
        view_capture.Height = view.ActiveViewport.Size.Height
        view_capture.ScaleScreenItems = False
        view_capture.DrawAxes = False
        view_capture.DrawGrid = False
        view_capture.DrawGridAxes = False
        view_capture.TransparentBackground = False
        bitmap = view_capture.CaptureToBitmap(view)
        if bitmap:
            folder = System.Environment.SpecialFolder.Desktop
            path = System.Environment.GetFolderPath(folder)
            filename = System.IO.Path.Combine(path, "SampleViewCaptureToFile.png");
            bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Png);


– Dale

Thanks, @dale , however I meant that the docs say that CaptureToBitmap() can take either a RhinoView (view in your example) or a ViewCaptureSettings, and it throws an error when I try to pass a ViewCaptureSettings object…


The overload is a static function so you’ll probably need to call it with
When you want to pass the ViewCaptureSettings class

Aaah of course… Thanks for pointing that out! :see_no_evil:

Any idea about the display style scaling in the first point?

Here are a couple of examples.

They are full-scale crops of screen capture at 7200x4800 to emphasize the difference.
The one on the left uses imageCap = viewCap.CaptureToBitmap(activeView) and the one on the right uses the static function imageCap = rc.Display.ViewCapture.CaptureToBitmap(vcSettings). The behaviour on the right, using the static method, is how it should be / has been in the past. Maybe it’s a feature, not a bug :wink:

Can you provide the code that you use to generate the image on the right? Maybe I can figure out which setting is different

Here you go, @stevebaer , it’s just using the static method instead of the other one:

activeView =  rc.RhinoDoc.ActiveDoc.Views.ActiveView
imageDim = System.Drawing.Size(width,height)

    vcSettings = rc.Display.ViewCaptureSettings(activeView, imageDim, 1)
    imageCap = rc.Display.ViewCapture.CaptureToBitmap(vcSettings)
    System.Drawing.Bitmap.Save(imageCap, path)


    return path

This version works like the image on the right.

For comparison, @stevebaer, this version works like the image on the left. Note that setting viewCap.ScaleScreenItems to True or False does not seem to have any effect.

activeView = rc.RhinoDoc.ActiveDoc.Views.ActiveView
imageDim = System.Drawing.Size(width,height)

    viewCap = rc.Display.ViewCapture()
    viewCap.DrawAxes = False
    viewCap.DrawGrid = False
    viewCap.Height = height
    viewCap.Width = width
    viewCap.TransparentBackground = False
    viewCap.ScaleScreenItems = False
    imageCap = viewCap.CaptureToBitmap(activeView)
    System.Drawing.Bitmap.Save(imageCap, path)


    return path