How to (de-)serialize GH-only geometry?

Hi there,

I am trying to get some form of string representation of geometry defined in Grasshopper only (ie, geometry NOT referenced from Rhino), like a GUID handle.
I’d need this is so I can interweave geometry into my custom components along with other data as comma separated values. Within my components I’m not doing anything with this geometry other than keeping track of and returning it.

Here is an example workflow how this could be used:

I know, I could simply have my sausage maker component accept multiple inputs instead of a comma separated input, but internally the sausage maker works with CSV data only.

Hope this kind of makes sense and someone out there can help me with my strange request…

-Jacob

1 Like

Hmm, I’m not sure if I get the idea of what you are trying to achieve, but I can tell you that generally you should be able to easily serialize and deserialize Rhino’s geometry using JSON :slight_smile:

Good pointer indeed!

For future reference, I’ve tested with C# script components and these are my code blocks:

serialization (to JSON):

var opts = new Rhino.FileIO.SerializationOptions();
opts.WriteUserData = true; // probably not needed, but who knows
A = x.ToJSON(opts);

deserialization (from JSON):

A= Rhino.Runtime.CommonObject.FromJSON(x);