algorithmic modeling for Rhino
In one of the recent releases of Grasshopper, the Export Quick Image interface was included with Grasshopper (which is pretty sweet). My question: is there a method which I can use to return a bitmap of the Rhino Viewport (like in the Toggle Viewport Frame button)?
Tags:
Rhino.Display.RhinoView.CaptureToBitmap(New Size(width, height))
Or use the ViewCaptureToClipboard command...
--
David Rutten
david@mcneel.com
Tirol, Austria
Thanks for the quick reply. However, when I type in Rhino.Display.RhinoView... I don't see the CaptureToBitmap method. Is this public?
It is public, but you need to call it on an instance of the RhinoView class. Not the on the class itself. I.e. in the Quick Export window, I use the following code:
Private Sub UpdateViewportImage()
Dim vp As Rhino.Display.RhinoView = Nothing
If (Not String.IsNullOrEmpty(ViewportName)) Then
For Each view As Rhino.Display.RhinoView In Rhino.RhinoDoc.ActiveDoc.Views
If (view.MainViewport.Name.Equals(ViewportName, StringComparison.OrdinalIgnoreCase)) Then
vp = view
Exit For
End If
Next
End If
If (vp Is Nothing) Then
vp = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView
End IfDim pts As PointF() = ViewportFramePoints
Dim width As Int32 = Convert.ToInt32(GH_GraphicsUtil.Distance(pts(0), pts(1)))
Dim height As Int32 = Convert.ToInt32(GH_GraphicsUtil.Distance(pts(0), pts(3)))
width = Math.Max(10, width)
height = Math.Max(10, height)Dim capture As Bitmap = vp.CaptureToBitmap(New Size(width, height))
If (capture IsNot Nothing) Then
If (ViewportImage IsNot Nothing) Then
ViewportImage.Dispose()
ViewportImage = Nothing
End If
ViewportImage = capture
ImagePanel.Invalidate()
End If
End Sub
--
David Rutten
david@mcneel.com
Tirol, Austria
Cool. Works like a charm. Thanks so much for the help.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by