Create PrintScreen (Not View Capture) from GH through custom script

I have the need to make PrintScreens (Not View Capture) from GH. Is there a custom script that allows this. I can only find resources to Capture a Viewport inside Rhino, however not the Windows Canvas. Any help is appreciated.
(still on Rhino 5 and GH 0.9.0076)

I think you’re looking for Graphics.CopyFromScreen method:

using System.Drawing;
using System.Drawing.Imaging;

private void RunScript(string path, bool run)
{
    if (run)
    {
    Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
    Graphics graphics = Graphics.FromImage(printscreen as Image);
    graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size);
    printscreen.Save(path, ImageFormat.Jpeg);
    }
}


Chris.gh (12.9 KB)

Hi Mahdiyar, Thanks for the feedback. Since I use GH 0.9.0076 the error is “1. Error (CS0103): The name ‘ImageFormat’ does not exist in the current context (line 75)” Any alternative?

Chris (Rhino 5 version).gh (14.9 KB)

Thanks so Much!. Now I am able to render an automatic sequence of images with Vray for GH, and by printscreening the Vr_ray frame buffer window, I can combine them into an animation.

I’m not a V-Ray user, but I guess there must be better way to automatically export sequence of images.

If you’re using V-Ray for Grasshopper, it seems that you only need to specify the Out Img of Render Component: More info
Rhino5_36001_RenderGH

If you’re using V-Ray for Rhino, it seems that you only need to turn Save Image option on from Settings > Render Output rollout: More info
https://docs.chaosgroup.com/download/attachments/28424829/36001_FilePath.png?version=1&modificationDate=1516902257000&api=v2

This only work in Production Mode. SO this is a One render, One Save to Img action. To render a new step, you have to manually do so. To my knowledge there is no way to trigger the ‘Render’ buildingblock via GH. I’ve be trying all morning to find a ‘hack’.

In Interactive Mode any change to your models triggers a re-render of the scene, but the ‘Out Img’ save doesn’t work as expected and and incremental count for your images doesn’t work.

The strange thing is, it re-saves, but the file path and name are not update. So your save image gets rewritten constantly.

But I hope to be proven wrong :wink: