Rendering with C#

Hello Together

I want to render my viewport with C# and automatically save the result to a specify directory. How would I be able to do that, I couldn’t find a proper guide to that. I managed to set a custom environment, render settings in C#, just how to render is missing.

Anyone experience with that?

Thanks already in advance!

Best Felix

When you say “render my viewport” do you actually mean call Render and then Save the Result to a directory?

Or do you mean take whatever is visible in your Viewport and save an image to disk of the view?

With render i meant rendering with Cycles and then saving the result. The camera position, target i defined in my view.

1 Like

The easiest way to accomplish what you are asking, is to just execute a Rhino Script to perform the render and then save the render window. Similar to this:

var savePath = Path.Combine(folder, $"{filename}.png");
RhinoApp.RunScript($@"!_Render _-SaveRenderWindowAs ""{savePath}""", true);
1 Like

Perfect, thanks Jason! I approached this waaay too complicated
You saved my evening :pray:t3:

1 Like