How to trigger a component serialization?

How can I trigger a component serialization in code, using C#?

I have implemented Read and Write (which works when, for example, saving the definition), but would like to trigger Write also by myself.

Are you looking for a new way to save your component? Then you could implement your own


and call the Write method yourself. Or, easier, just use a new empty

In general, though, this is the task of the
which you can use to read/write a definition.

@DavidRutten might be able to tell more.



Giulio Piacentino
for Robert McNeel & Associates

I’m happy to write to the existing archive, I’m just not sure how to do that.

I’m confused too. What problem are you solving? And do you want to end up with a byte[], a MemoryStream, a *.gh file, or…?

Either way, it’s quite straightforward as long as you have access to GH_IO.dll, which you almost always do. (31.7 KB)

var chunk = new GH_LooseChunk(null);
Bin = chunk.Serialize_Binary();
Xml = chunk.Serialize_Xml();


Got it! I realize the question wasn’t very clear, but you’ve answered it.
(Basically I wasn’t sure how to use Write.)