Capturing Rhino layout/viewport iterations - print or image export

Greetings -

I have a script that iterates through several geometries, displaying them in the Rhino viewport- and I’d like to capture an image of each iteration. I’ve combed through topics from printing to screen capturing, but haven’t found a working example that can reliably be incorporated into a script.

Ideally the solution could be incorporated into a Python component in grasshopper - and could save files (either as PDFs or images) with unique filenames.

See old topics on the subject:

Rhino command for print settings:

Print layout from GH:

Print Settings control from GH:

Any recent developments here? Thanks

It’s problematic because the viewport will not be redrawn until after the solution completes. So you cannot get an image of the current solution while you’re part of that solution.

Somehow you will have to wait until the solution you care about completes, and then capture the image.

Actually it sort of works. As long as the script component is on top of everything else (meaning it gets solved last) you can force a viewport update mid-solution. (16.0 KB)

1 Like

@DavidRutten I don’t really understand what you meant by ‘on top of everything’. how do you make sure a certain script component to get solved last?

Hi David,

It works very well for me but in the saved image is appearing the grid even if on the viewport it doesn’t exist. How can I eliminate the grid from the image?
Thank you!

Double click the C# component and change this line:

Bitmap image = view.CaptureToBitmap(true, false, false);

into this:

Bitmap image = view.CaptureToBitmap(false, false, false);
1 Like

Thank you very much!

For others who had this same question, I believe this is what is meant by “on top”, meaning “Bring To Front”:

From David’s example -
This arrangement will cause the view capture to happen after the viewport is updated

This arrangement will cause the view capture to happen before the viewport is updated

Hi David,

Thanks for this script! I am just wondering if it’s possible to select a layout page instead of a viewpoint?
I am trying to export a screenshot of the Layout at every rotation angle.