C# Exporting Component Image(.png) antomatically

(Shimpei) #1


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.



(David Rutten) #3

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?

(Shimpei) #4


Thanks for your reply.

Exactly, that’s what I wanted.

(David Rutten) #5

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.

(Shimpei) #6


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?

(David Rutten) #7

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.

(Shimpei) #8

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!


1 Like