Create bitmap from GH canvas via script

grasshopper

#1

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


#2

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 ()


#3

Thanks Dani,

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

Laszlo


(David Rutten) #4

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).


#5

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


#6

hmm

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


(David Rutten) #7

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.