Can't save Python classes : it.wall.Wall and it.ball.Ball objects

I tired to save ball and wall objects into the PFC3D save file but failed

get_ipython().magic('reset -sf') #command to initialize iPython environment

import itasca as it

it.command("python-reset-state false") #the model new command will not affect python environment

model new
model domain extent -0.1 0.1
ball create id 1 position (0,0,0) radius 0.01
wall generate id 1 name 'test' polygon (-0.1, -0.1, -0.05), (0.1, -0.1, -0.05), (0.1, 0.1, -0.05), (-0.1, 0.1, -0.05)

wall_id_1 = it.wall.find(1)
ball_id_1 = it.ball.find(1)



model save 'test_220529.sav'

The error message is

ValueError: Error while trying to save the Python object: wall_id_1. Either this object itself or something contained in the object cannot be serialized. Itasca uses the dill Python module for serialization. A description of what can and cannot be serialized can be found here: The error message follows:

Internal error while calling Python function pickle_dump from module _itasca_internal. The error message was "<class 'TypeError'>"
"can't pickle itasca.wall.Wall objects"
  File "C:\Program Files\Itasca\PFC700\exe64\python36\lib\", line 28, in pickle_dump

  File "C:\Program Files\Itasca\PFC700\exe64\python36\lib\", line 409, in dump

  File "C:\Program Files\Itasca\PFC700\exe64\python36\lib\", line 496, in save
    rv = reduce(self.proto)

    While processing line 0 of source Python interpreter.

How can I save it?

Hi @ppk!

As the error message details, Itasca softwares use the dill library to serialize objects.
Citing the documentation:

dill extends python’s pickle module for serializing and de-serializing python objects to the majority of the built-in python types

I guess that Python objects are APIs to native Itasca objects (C++?) and no pure Python objects, I am afraid you cannot save these.
The workaround would be to store your objects through their IDs:

wall_1 = 1

Then, restore them in your later sessions:

wall_id_1 = it.wall.find(wall_1)

NB : serialization is the process of storing high-level data into simpler, transmittable datastructures, such as bytes or byte code in Python.