KmolYuan / Pyslvs-UI

An open source planar linkage mechanism simulation and mechanical synthesis system.
https://pyslvs-ui.readthedocs.io
GNU Affero General Public License v3.0
194 stars 37 forks source link

[BUG] Pyslvs crashed on import SLVS saved with nightly SolveSpace 3.0 #28

Closed ghost closed 5 years ago

ghost commented 5 years ago

Describe the bug

Pyslvs crashed on import SLVS saved with nightly SolveSpace 3.0

To Reproduce

Steps to reproduce the behavior:

  1. Create SLVS file using nightly build of SolveSpace 3.0;
  2. Launch Pyslvs
  3. Go to "File > Load File"
  4. Select "Solvespace module"; (NOTE: Typo mistake - should be named as "SolveSpace 2.0")
  5. Select SLVS file created using nightly build of SolveSpace 3.0;
  6. Push "Open" button;
  7. Pyslvs silently crashed immediately.

Terminal Log

``` $ ./pyslvs-19.09.0.post0.glibc2.3.3-x86_64.AppImage Pyslvs 19.09.0.post0 OS Type: Linux 4.15.0-1-amd64 [x86_64] Python Version: 3.8.0(beta) Python Compiler: GCC 5.4.0 20160609 Qt wrapper: PyQt5 5.13.1 Qt Version: 5.13.0 ------- Startup with: 7.31s Connect to GUI console. Traceback (most recent call last): File "/var/tmp/.mount_pyslvswdOJEE/usr/bin/pyslvs_ui/core/main_window/io.py", line 319, in __load_file self.__read_slvs(file_name) File "/var/tmp/.mount_pyslvswdOJEE/usr/bin/pyslvs_ui/core/main_window/io.py", line 108, in __read_slvs self.parse_expression(parser.parse(group.split('@')[0])) File "/var/tmp/.mount_pyslvswdOJEE/usr/bin/pyslvs_ui/core/io/slvs/read.py", line 111, in parse entity['Entity.actPoint.x'], KeyError: 'Entity.actPoint.x' Aborted ```

Expected behavior

Pyslvs should load SolveSpace 3.0 file format.

Possibly, need create separate import options for "SolveSpace 2.0 module" and "SolveSpace 3.0 module"

Desktop

Additional context

Sample SLVS - https://gist.github.com/Symbian9/cdc817e7f33f3eabd66ea04e032b3342

Nightly builds of SolveSpace 3.0:

KmolYuan commented 5 years ago

In the nightly builds, the value equals zero will be removed in the file, so use "dict.get" method instead of "get item" operator.