realthunder / FreeCAD_assembly3

Experimental attempt for the next generation assembly workbench for FreeCAD
GNU General Public License v3.0
885 stars 74 forks source link

Errors when saving file with Assembly3 #1324

Open ivtts opened 10 months ago

ivtts commented 10 months ago

With FreeCAD 0.21.2, when save file with Assembly3, on console printed errors

PropertyPythonObject::toString(): failed for <class 'freecad.asm3.assembly.Assembly'>
Traceback (most recent call last):
  File "/usr/lib/python3.11/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
<class 'TypeError'>: Object of type set is not JSON serializable
PropertyPythonObject::toString(): failed for <class 'freecad.asm3.assembly.AsmConstraintGroup'>
...

It seems that class 'TypeError' Object of type FeaturePython is not JSON serializable the problem was related with git commit fbe2fef

It seems that when using python >=3.11 you need to rename the __getstate__/__setstate__ methods to dumps/loads. I tried doing this locally and now there are no errors.

My setup

OS: Arch Linux (XFCE/Xfce Session)
Word size of FreeCAD: 64-bit
Version: 0.21.2.33771 (Git)
Build type: Release
Branch: makepkg
Hash: b9bfa5c5507506e4515816414cd27f4851d00489
Python 3.11.6, Qt 5.15.11, Coin 4.0.1, Vtk 9.3.0, OCC 7.7.2
Locale: Russian/Russia (ru_RU)
Installed mods: 
  * DynamicData 2.60.0
  * Assembly4 0.50.6
  * Manipulator 1.5.6
  * Help 1.0.3
  * QuickMeasure 2022.10.28
  * Woodworking-0.20 0.20.29177
  * A2plus 0.4.61
  * TabBar
  * Assembly3 0.12.0
wsteffe commented 10 months ago

I am also having an error when saving from asm3 with last LinkStable on Windows 10. When it happens FC is frozed and I have to kill it in task manager. Saving same document with last LinkStable in Linux doesn't give any error. So may be it is a similar but a different problem than here reported.

image

wsteffe commented 10 months ago

I will report it as a new issue because I have just seen that issue reported here was already fixed in https://github.com/realthunder/FreeCAD_assembly3/commit/b0ba75422fed587d751b7bb3f0fd51c634c00090