mozman / ezdxf

Python interface to DXF
https://ezdxf.mozman.at
MIT License
912 stars 191 forks source link

ValueError: could not convert string to float: '1.000000000000000E 20' 285, tagger.py #601

Closed tatarize closed 2 years ago

tatarize commented 2 years ago

If this is not enough to identify the issue, please close this issue. I have no additional information or the original file needed to reproduce it. I simply get crash logs from a heavily used program that includes ezdxf for reading.

MeerK40t crash log. Version: 0.7.0 RC-6 on win32
Traceback (most recent call last):
  File "ezdxf\lldxf\tagger.py", line 285, in tag_compiler
ValueError: could not convert string to float: '1.000000000000000E 20'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "meerk40t\gui\wxmeerk40t.py", line 2797, in on_click_open
  File "meerk40t\gui\wxmeerk40t.py", line 2504, in load
  File "meerk40t\core\elements.py", line 4524, in load
  File "meerk40t\dxf\dxf_io.py", line 52, in load
  File "ezdxf\filemanagement.py", line 154, in readfile
  File "ezdxf\filemanagement.py", line 94, in read
  File "ezdxf\document.py", line 282, in read
  File "ezdxf\document.py", line 296, in load
  File "ezdxf\document.py", line 309, in _load
  File "ezdxf\lldxf\loader.py", line 88, in load_dxf_structure
  File "ezdxf\lldxf\tags.py", line 295, in group_tags
  File "ezdxf\lldxf\tagger.py", line 291, in tag_compiler
ezdxf.lldxf.const.DXFStructureError: Invalid floating point values near line: 820.
tatarize commented 2 years ago
MeerK40t crash log. Version: 0.7.4-beta2 on win32 - 4.1.1 msw (phoenix) wxWidgets 3.1.5
Traceback (most recent call last):
  File "meerk40t\gui\wxmribbon.py", line 189, in <lambda>
  File "meerk40t\kernel.py", line 136, in __call__
  File "meerk40t\kernel.py", line 1822, in console
  File "meerk40t\kernel.py", line 1908, in _console_parse
  File "meerk40t\kernel.py", line 1260, in inner
  File "meerk40t\gui\wxmmain.py", line 320, in load_dialog
  File "meerk40t\gui\wxmmain.py", line 1558, in load
  File "meerk40t\core\elements.py", line 6489, in load
  File "meerk40t\dxf\dxf_io.py", line 66, in load
  File "ezdxf\filemanagement.py", line 149, in readfile
  File "ezdxf\filemanagement.py", line 92, in read
  File "ezdxf\document.py", line 337, in read
  File "ezdxf\document.py", line 352, in load
  File "ezdxf\document.py", line 365, in _load
  File "ezdxf\lldxf\loader.py", line 89, in load_dxf_structure
  File "ezdxf\lldxf\tags.py", line 288, in group_tags
  File "ezdxf\lldxf\tagger.py", line 298, in tag_compiler
ezdxf.lldxf.const.DXFStructureError: Missing required y coordinate near line: 18.

While we're at it.

mozman commented 2 years ago

These are what the error message says DXF Structure Errors and your application or the library which uses ezdxf has to catch these exception. There are many "DXF files" in the wild that have minor and/or major flaws.

A section of the ezdxf documentation shows the recover module and how to load DXF files from unreliable sources.

The first error is an invalid floating point value: '1.000000000000000E 20`

A space inside a floating point value? This is fixed by the recover tool but as 1.0 and not as 1e+20!

The second is a weird but valid ordering of the x-, y- and z-axis of a vertex, which the recover module should fix.

I am aware of the second error from an old version of QCAD or LibreCAD in which the coordinates of LINE entities were written in the order x1, x2, y1, y2, z1, z2.

If the recover module can't fix the second error, posting the zipped DXF file including the error may help to improve the recover module.

mozman commented 2 years ago

The software which use ezdxf is your application meerK40t:

https://github.com/meerk40t/meerk40t/blob/2dce49e0d261998fdb224f7349b18e8513730cd5/meerk40t/dxf/dxf_io.py#L66

Follow the instruction in documentation to the recover module to harden your DXFLoader.load() method.