Hi Nathan,
Thanks for you comment. I tried to do what you suggested but have a weird problem.
What I did is to set target display mode and apply this mode to current viewport.
and then save the view and re-change display mode to original mode.
But, the problem is that generated image is still under original display mode. I think when running the code, generating image takes some time and the display mode is changed fast, so capturetobitmap couldn’t pick the target display mode.
I tried to put some sleep but didn’t work.
Could you give me some advice here?
Thanks!
import System
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
view = sc.doc.Views.ActiveView
target_display_mode = Rhino.Display.DisplayModeDescription.FindByName("WireFrame")
view.ActiveViewport.DisplayMode = target_display_mode
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:
path = 'C:/Users/Lei/Desktop/temp/'
folder = System.Environment.SpecialFolder.Desktop
filename = System.IO.Path.Combine(path, "SampleViewCaptureToFile.jpg")
bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg)
view = sc.doc.Views.ActiveView
original_display_mode = Rhino.Display.DisplayModeDescription.FindByName("Shaded")
view.ActiveViewport.DisplayMode = original_display_mode