Create bitmap from GH canvas via script

Hello Rhino Team,

Has it any option, method to save image from grasshopper canvas?

Such as ScreenCaptureToFile command in rhino?

Thanks,

Laszlo Szabo
QA Test Automation Engineer
GRAPHISOFT SE

Grasshopper.Instances.ActiveCanvas.DrawToBitmap or
Grasshopper.Instances.ActiveCanvas.CreatePreview or
Grasshopper.Instances.ActiveCanvas.GenerateHiResImage or
Grasshopper.Instances.ActiveCanvas.GetCanvasScreenBuffer,
one of these creates you an image that you can save from Bitmap.Save ()

1 Like

Thanks Dani,

Can i use with vbs script? Can you show me a sample code?

Laszlo

No, Grasshopper doesn’t support VBScript at all. You’ll have to use either VB.NET, C# or Python (or, if you know how, other .NET compliant languages such as F# or C++/CLI).

Grasshopper.Instances.ActiveCanvas.GetCanvasScreenBuffer(Grasshopper.GUI.Canvas.GH_CanvasMode.Export).Save(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + “\ \CaptureCanvas.png”);
(delete the space between \ and \ )

hmm

It seems to be not working, i attach my codescreencapture.vbs.txt (2.7 KB)

These are not commands in the Rhino sense, they are API methods. You posted this in the Grasshopper Developer category which is why people are giving you source code. There’s no way to do this using commands, you have to invoke the Grasshopper SDK through code.