mozman / dxfgrabber

Outdated DXF reader, please switch to ezdxf (UNMAINTAINED)
Other
67 stars 15 forks source link

Handle the tag codes that are in a different order #12

Closed goatchurchprime closed 6 years ago

goatchurchprime commented 6 years ago

I got the "Missing required y coordinate" error from a DXF output by Alphacam, similar to issue #4 where dxfgrabber requires the order of tags to be: 10(startX), 20(startY), 11(endX), 21(endY); but the order in my file is: 10(startX), 11(endX), 20(startY), 21(endY)

This unexpected order can also be seen on an example on the Autodesk forum: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/converting-to-single-layer-single-section-dxf-for-2d-polygon/td-p/3096212

Also, page 61 of the AutoCAD 2012 reference specifications http://images.autodesk.com/adsk/files/autocad_2012_pdf_dxf-reference_enu.pdf says:

NOTE: Do not write programs that rely on the order shown in these DXF code tables. Although these tables show the order of group codes as they usually appear, the order can change under certain conditions or may be changed in a future AutoCAD release. The code that controls an entity should be driven by a case (switch) or a table so that it can process each group correctly even if the order is unexpected.

mozman commented 6 years ago

Hi!

The note about the order of group codes was absolute true for DXF versions til R12, but as they introduced entities like LWPOLYLINE, HATCH or SPLINE, this is not really true because some group code appear multiple times like vertex coordinates 10 and 20 and the order of their appearance is significant.

But anyway, the expected order of coordinates in dxfgrabber/ezdxf is an optimization and works for all DXF files produced by AutoCAD and most other CAD applications, there was an older QCAD version that also wrote LINE coordinates as x1, x2, y1, y2, but they changed (fixed) that in a later version and now Alphacam (which i don't know) seem to be another CAD application which has this behavior.

I will not sacrifice the coordinate optimizations for one or two applications/libs. If this is a show stopper for you, you can't use dxfgrabber/ezdxf, sorry.

goatchurchprime commented 6 years ago

Is it possible to share in the docs your best source for the specification documentation of DXF to help people like me to track down interface bugs of the kind I keep finding?

mozman commented 6 years ago

The official DXF Reference by Autodesk are the 'best', because that is the only one, the rest is the trail and error method.

DXF Reference: http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-235B22E0-A567-4CF6-92D3-38A2306D73F3

AutoCAD 2018 Developer Docs: http://help.autodesk.com/view/OARX/2018/ENU/