Screenshot of Viewport - Grasshopper2024-03-28T13:22:30Zhttps://www.grasshopper3d.com/forum/topics/screenshot-of-viewport?commentId=2985220%3AComment%3A924261&feed=yes&xn_auth=noGreat I mark it.tag:www.grasshopper3d.com,2015-06-04:2985220:Comment:13022412015-06-04T06:23:39.488Zhuaxiamengqinghttps://www.grasshopper3d.com/profile/huaxiamengqing
Great I mark it.
Great I mark it. Cool. Works like a charm. T…tag:www.grasshopper3d.com,2013-10-02:2985220:Comment:9242002013-10-02T12:58:45.516ZAndy Paynehttps://www.grasshopper3d.com/profile/AndyPayne
<p>Cool. Works like a charm. Thanks so much for the help.</p>
<p>Cool. Works like a charm. Thanks so much for the help.</p> It is public, but you need to…tag:www.grasshopper3d.com,2013-10-02:2985220:Comment:9241982013-10-02T12:29:03.471ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<p>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:</p>
<p></p>
<blockquote><p>Private Sub UpdateViewportImage()<br></br> Dim vp As Rhino.Display.RhinoView = Nothing<br></br> If (Not String.IsNullOrEmpty(ViewportName)) Then<br></br> For Each view As Rhino.Display.RhinoView In Rhino.RhinoDoc.ActiveDoc.Views<br></br> If (view.MainViewport.Name.Equals(ViewportName,…</p>
</blockquote>
<p>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:</p>
<p></p>
<blockquote><p>Private Sub UpdateViewportImage()<br/> Dim vp As Rhino.Display.RhinoView = Nothing<br/> If (Not String.IsNullOrEmpty(ViewportName)) Then<br/> For Each view As Rhino.Display.RhinoView In Rhino.RhinoDoc.ActiveDoc.Views<br/> If (view.MainViewport.Name.Equals(ViewportName, StringComparison.OrdinalIgnoreCase)) Then<br/> vp = view<br/> Exit For<br/> End If<br/> Next<br/> End If<br/> If (vp Is Nothing) Then<br/> vp = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView<br/> End If</p>
<p>Dim pts As PointF() = ViewportFramePoints<br/> Dim width As Int32 = Convert.ToInt32(GH_GraphicsUtil.Distance(pts(0), pts(1)))<br/> Dim height As Int32 = Convert.ToInt32(GH_GraphicsUtil.Distance(pts(0), pts(3)))<br/> width = Math.Max(10, width)<br/> height = Math.Max(10, height)</p>
<p>Dim capture As Bitmap = vp.CaptureToBitmap(New Size(width, height))<br/> If (capture IsNot Nothing) Then<br/> If (ViewportImage IsNot Nothing) Then<br/> ViewportImage.Dispose()<br/> ViewportImage = Nothing<br/> End If<br/> ViewportImage = capture<br/> ImagePanel.Invalidate()<br/> End If<br/> End Sub</p>
</blockquote>
<p>--</p>
<p>David Rutten</p>
<p>david@mcneel.com</p>
<p>Tirol, Austria</p> Thanks for the quick reply. …tag:www.grasshopper3d.com,2013-10-02:2985220:Comment:9242612013-10-02T12:22:44.011ZAndy Paynehttps://www.grasshopper3d.com/profile/AndyPayne
<p>Thanks for the quick reply. However, when I type in Rhino.Display.RhinoView... I don't see the CaptureToBitmap method. Is this public?</p>
<p>Thanks for the quick reply. However, when I type in Rhino.Display.RhinoView... I don't see the CaptureToBitmap method. Is this public?</p> Rhino.Display.RhinoView.Captu…tag:www.grasshopper3d.com,2013-10-02:2985220:Comment:9242582013-10-02T12:15:22.364ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<p>Rhino.Display.RhinoView.CaptureToBitmap(New Size(width, height))</p>
<p></p>
<p>Or use the ViewCaptureToClipboard command...</p>
<p></p>
<p>--</p>
<p>David Rutten</p>
<p>david@mcneel.com</p>
<p>Tirol, Austria</p>
<p>Rhino.Display.RhinoView.CaptureToBitmap(New Size(width, height))</p>
<p></p>
<p>Or use the ViewCaptureToClipboard command...</p>
<p></p>
<p>--</p>
<p>David Rutten</p>
<p>david@mcneel.com</p>
<p>Tirol, Austria</p>