ixmilia / dxf

MIT License
221 stars 67 forks source link

XData group code exception when casting to string #180

Open croggero opened 2 years ago

croggero commented 2 years ago

I am getting a "System.InvalidCastException : Unable to cast object of type 'System.Double' to type 'System.String'." when trying to parse a DXF created with AutoCAD 2017. The group code in question is 1040 (see https://help.autodesk.com/view/OARX/2020/ENU/?guid=GUID-A2A628B0-3699-4740-A215-C560E7242F63) when reading XData. The error occurs on the following line.

https://github.com/ixmilia/dxf/blob/7149f0b11384c2dc44a0de1f28e0e322dc11c115/src/IxMilia.Dxf/IDxfHasXData.cs#L26

The DXF lines are

...
330
10000001
100
AcDbXrecord
1040
86.0
  0
ACAD_PROXY_OBJECT
  5
10000005
...
brettfo commented 2 years ago

Can you share the full DXF file with me? Also, can you share the steps you used to create that file? According to the spec link you provided that file is incorrect.

Each registered application group begins with a 1001 group code

The code is failing because it's expecting something like 1001/SomeAppId to appear before the 1040 code (which is a double.)

Obviously, AutoCAD isn't following their own spec (I've found numerous instances where this is the case), but I'd like for this library to work with it, but I'd like to better understand exactly how a drawing gets in to that state as well as what the expected behavior is.

My guess is that in a case like this where there's no 1001 application code, I can likely assume the application code to be "ACAD", but I'd like to explore a bit more.