netDxf
netDxf copied to clipboard
DXF 2004
Unfortunately it doesn't read dxf files in 2004 format
in void BuildLayerStateManager
Layer layer = (Layer) this.doc.GetObjectByHandle((string) recordEntry.Value);
if (layer is null)
{
enumerator.MoveNext();
continue;
}
this will fix the situation
Please post your DXF. I didn't see any problems with files saved as 2004 generated by a later version of AutoCad. From what you wrote seems that the handle of the layer is not found and that should not happen, errors with handles in a DXF usually ends up in a total crash when loaded in AutoCad. What program generated your file?
The file was saved in Autodesk AutoCAD 2017. But it doesn't really depend on the version. TEST.zip
I think you have uploaded the wrong file. It didn't give me any problems and it doesn't contain any layer state.
and I check on different computers
the library cannot read the DXF 2004 format everywhere unless you make the above edits
The problem here is not if that check is needed or not. I will add it just to avoid possible problems with bad handles, issue that it is the result of a bad DXF.
The problem here is that you are posting DXFs that do not contain any layer state, the dictionary is there but there are no XRecords that hold the layer state data. If there are no XRecords the code you are editing will not be executed , therefore your modifications should not fix anything. Something else must be happening here and that is what confuses me.
Try the attached DLLs with the DXFs files you have uploaded, they are compiled from the latest source code found in the repository. Let's see what happens, oh! and there is no need to change computers.
This compilation read DXF 2004. Thank you for your work, it's really cool.