Back before Rhino8, we used to rely on pickle to easily serialize custom class instances to file. This was very useful for complex scripting applications. With R8/py3, it is no longer possible to serialize .NET objects (such as Rhino.Geometry.Brep). Does anyone have a good workaround for this issue?
The other impact of this is that we can no longer use python’s copy module to create a deepcopy of a class instance either.
Thanks for the reply, somehow I missed the thread from last year when I searched the forums. We’re currently looking into using jsonpickle to handle serialization by adding handlers for Rhino structs (Plane, Vector etc). But you mentioned that “I have a ticket here to get this implemented” - how likely is that to happen in the near future?
Going back to py2 is no longer an option for us I’m afraid.
Here’s a working solution based on jsonpickle. Our testing is limited but includes complex, nested python classes with shared objects and cyclical graphs, which jsonpickle seems to handle well. The caveat is that you need to create and register handlers for rhino structs if needed - see the docstring comments. We’ve included only what we needed. RhinoSerializable.py (9.7 KB)
Hi @will8 I am sorry for the late reply. I have moved this to my work for Rhino 9 and will look deeper into it to see how I can implement this internally in Python 3