Example on how to use GH_IO.dll

Hello David,

We are trying to manipulate GH files from an external C# application.

I saw the post on : http://wiki.mcneel.com/labs/grasshopper_fileformat

concerning GH_IO.dll which say:

"..You can reference this library from any DotNET assembly since it only depends on standard System namespaces. Library is fully documented."

However, I could not make it work. For some reason, the code in GH_IO.dll can not be accessed.

Can you please upload the simplest C#/VB application (project) that uses GH_IO.dll to open/modify GH files? 

Tanir

  • up

    David Rutten

    Hi Tanir,

    note that GH_IO.dll does not represent the GH/GHX file formats, nor does it contain tools for editing GH/GHX files.

    GH_IO.dll is only a type-safe, hierarchical database which can (de)serialize itself to xml and binary streams. Grasshopper uses GH_IO.dll to write almost all of its files (gh/ghx, settings, canvas skins, MRU data, Markov-chain data, etc. etc.)

    What you can do with GH_IO.dll is read a gh/ghx file and get a runtime representation of that file in the aforementioned type-safe, hierarchical database format.

    The basic building-block of this database is called a Chunk. A Chunk contains any number (zero to Int32.MaxValue) of Items and sub-chunks. An Item is a named value, which can have an optional index as well. So multiple items can share the same name, while being only differentiated by their indices.

    I attached a gh file with a C# component that reads a Grasshopper files, replaces a bunch of characters in object names and then saves it under a different name. You can use TestFile.gh to try it out.

    --

    David Rutten

    david@mcneel.com

    Poprad, Slovakia