C# Exporting Component Image(.png) antomatically

Hi

I’m trying to make textbook for GH beginner(student).
I think it takes a lot of time to export component image one by one.

Is there any easy way to export component images automatically?
I can use a bit of C# and python.

image

Best,
Shimpei

You want to generate images at some zoom level of all the components in a file, with their names and states, but without any wires? Presumably with a transparent background?

David

Thanks for your reply.

Exactly, that’s what I wanted.

This may be a start. It’s not guaranteed to work for all objects, as it depends on a specific implementation of a protected method. However doing it the right way requires the existence of a canvas control which makes things a lot harder. The script in this file makes no changes at all, merely calls the Render() method on all individual objects with a properly set up graphics object: component image painter.gh (16.1 KB)

Zoom and padding controls are inside the script somewhere.

6 Likes

David,

Amazing!
It’s very helpful.

I want to categorize these component, and I found that IGH_DocumentObject has “Name”,“NickName”…etc.

Does IGH_DocumentObject have also Input Params name and description?

No, everything in the document is an IGH_DocumentObject, floating parameters, components, scribbles, jumps, groups, Galapagos, …

Only components have input and output parameters, so you’ll need to cast your IGH_DocumentObject to an IGH_Component first. If that conversion is possible, you can then interrogate its parameters.

Finally, I succeeded to convert my IGH_DocumentObject to an IGH_Component and get params Name,NickName,Descriotion.

Here attached is exported component information as .csv.

Thanks a lot, David!

Best,
Shimpei

1 Like

Hey @DavidRutten
We have a similar situation that we’re trying to figure out. In our case, we have many plugins developed in-house that automatically generate a documentation file every time a new version is released.
Our components all generate an automatic layout when inserted into the canvas (see example image below). We would like to capture these layouts’ screenshots for the documentation within our pipeline - that uses Rhino.Inside to run Grasshopper Tests and builds the plugin’s .yak package - which means we don’t really open Grasshopper during this process (no ActiveCanvas).

Is there a way to programmatically generating these files with each component’s layout and getting their screenshots without an ActiveCanvas?