So I somewhat modified the script as show below.
Note that the input curve is meant to parallel to the correspond view plane.
As I mentioned at first I’m really new to scripting…all I did is shuffle and messing around in the script.
One thing I noticed is Redraw
in the script seems take a bit of time.
Please give any suggestion or thought if anywhere I can improve, I’ll be very appreciated.
CaptureViewRectangle.gh (103.1 KB)
import Rhino
import System.Drawing
import Rhino.Geometry as rg
import scriptcontext as sc
import rhinoscriptsyntax as rs
import Rhino.Display as rd
import System
pt0 = frame[0]
pt1 = frame[1]
pt2 = frame[2]
pt3 = frame[3]
width = rg.Point3d.DistanceTo(pt0, pt1)
height = rg.Point3d.DistanceTo(pt1, pt2)
size = 'w=' + str(int(width*fector)) + ', ' + 'h=' + str(int(height*fector))
def Capture():
RhinoDocument = Rhino.RhinoDoc.ActiveDoc
selectview = RhinoDocument.Views.Find(view, False)
size = System.Drawing.Size(int(width*fector),int(height*fector))
settings = rd.ViewCaptureSettings(selectview, size, 300) #view, size, dpi
settings.SetWindowRect(pt0, pt2)
settings.RasterMode = True
settings.DrawGrid = False
settings.DrawAxis = False
settings.DrawWallpaper = False
bitmap = rd.ViewCapture.CaptureToBitmap(settings)
bitmap.Save(path+filename+".png")
if save:
RhinoDocument = Rhino.RhinoDoc.ActiveDoc
selectview = RhinoDocument.Views.Find(view, False)
rs.ViewDisplayMode(view, mode)
rs.Redraw()
Capture()
print(path+filename+".png")