haplokuon / netDxf

.net dxf Reader-Writer
MIT License
990 stars 401 forks source link

LibreCAD generated files don't load. #228

Open computergeek1507 opened 3 years ago

computergeek1507 commented 3 years ago

I exported the attached files with the LibraCAD Nightly and neither load. One is AutoCAD2007 and the second is AutoCAD2004 format.

dxfs.zip

haplokuon commented 3 years ago

Both files Untitled3.dxf and untitled4.dxf are bad files, even AutoCAD will crash trying to load them. The problem lies on writing a non hexadecimal number in code 340. You should report this bug to LibreCAD. The official DXF documentation is awful, but the only thing that makes it clear is the code-value correspondence. I am adding several new checks for invalid values in buggy DXF files, but, in any case, this kind of errors in a DXF file are unacceptable.

computergeek1507 commented 3 years ago

Is the 340 with the "STANDARD" the problem? The second 340 is a value for the 5 code above it, I think.

Screen Shot 2021-02-17 at 12 18 55 AM

Screen Shot 2021-02-17 at 12 21 08 AM

haplokuon commented 3 years ago

Correct. The data in a DXF is always stored in pairs (code-value) therefore odd line numbers are always codes, while even lines are values. Code 340 must be followed by an hexadecimal number, in your second image it just happens that the handle for the LwPolyline entity, code 5 is 340.