Serializing to file

@AndersDeleuran,

Hi,

What do you mean by serializing RhinoCommon and custom objects to files? You save each object into separate 3dm files?

Then deserialize to put them back in GH?

Thanks in advance.

BR
Ivelin

Also, did that really need a new thread?

No, I tried to PM you but you’ve deactivated it. And it would’ve been way too off-topic if I asked in the other thread. Since it was about Csharp.

Specifically to GHPython, I tend to structure RhinoCommon geometry data and more primitive types (floats, integers, strings, booleans) into a dictionary. And then pickle/unpickle (i.e. serialise) that to/from file using the standard pickle module:

https://ironpython-test.readthedocs.io/en/latest/library/pickle.html

Note that there’s also the cpickle standard module, and that not all data types will pickle. If you’re only interested in primitive types, I’d advice to use the standard json module instead, making the data file universal.

2 Likes

Thanks Anders,

Is using Pickle somehow faster than using .net System.Runtime and System.IO?