Saving class instance with pickle

Hi everyone,

I saved a mesh and a class instance with pickle to a pickle file:

with open(‘test.pickle’, ‘wb’) as fileout:
pickle.dump(mesh, fileout)

with open(‘test.pickle’, ‘rb’) as filein:
myfile = pickle.load(filein)

however, I got the following errors when I call back the file:

Runtime error (NullReferenceException): Object reference not set to an instance of an object.

Traceback (most recent call last):
SystemError: Object reference not set to an instance of an object.

When calling back a class instance:
Runtime error (ImportException): No module named main

Traceback:
line 1130, in find_class, “C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\pickle.py”
line 1075, in load_inst, “C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\pickle.py”
line 864, in load, “C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\pickle.py”
line 1384, in load, “C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\pickle.py”
line 19, in script

those errors appear when i call back the files

Do you have the same problem with this file?
Pickle.gh (2.6 KB)

thanks dude, I’ve found the problem. The brep i was saving is in GUID type. I convert it into rhino mesh using rs.coercemesh and everything is fine

What about class instance?
I have a class instance like the following:

class Class1:
def init(self):
self.prop1 = 1

obj1 = Class1()

Can i save obj1 using pickle too?