As part of a C# plugin for Rhino I am trying to construct images from views using the default renderer for Rhino. I saw a [post from a year ago that suggested this was possible in c++] ( Change viewport “camera” and render to image file) but I am having trouble finding similar functions such as “renderToDC” in C#. Any suggestions? I’ve looked through the developer docs and haven’t had any luck so far.
var view = doc.Views.ActiveView; var bitmap = view.CaptureToBitmap(new Size(800, 600));
Just what I was looking for. Thanks Dale!
I’ve had some time to play around with this more and have some follow up questions @dale.
1.) I’ve seen that it’s possible to create a RhinoViewport, position it, and set the camera target within a plugin but to capture the image as described above requires having a RhinoView. So far I’ve been unable to create RhinoViews and am wondering if there is someway to do so as there doesn’t seem to be a constructor in the docs?
2.) Is it possible within a plugin to create a rendered image using the default rendered plugin? I know you can call the render command, but it doesn’t seem like you can control the location or direction from which the rendering is captured.
No, I don’t believe so.
Scripting the Render command is the way to go. The Render command gets its camera information from the active viewport. To save the contents of the render window, use the SaveRenderWindowAs command. You can close the render window using CloseRenderWindow.