DomCR / ACadSharp

C# library to read/write cad files like dxf/dwg.
MIT License
386 stars 111 forks source link

Reading some dwg-files results null values for CadDocument.ModelSpace and PaperSpace #178

Closed thorster closed 10 months ago

thorster commented 10 months ago

Describe the bug Great work with ACadSharp! Just recently started to use it to read dwg-files and extract text from block attributes, All worked fine for the first batch of 600+ dwg-files. Now with a second batch something goes wrong. The CadDocument properties ModelSpace and PaperSpace are both null and a null-reference exception is thrown when my code access the property Entities.

To Reproduce This code should reproduce the issue:

            using var reader = new DwgReader("691501_14101.dwg");
            var doc = reader.Read();
            var entities = doc.Entities;

The dwg-file: 691501_14101.zip

Expected behavior The dwg-files are created in BricsCAD. I have opened a dwg-file in AutoCAD and used the command AUDIT but no errors where found. Saved the file in AutoCAD but still same behaviour in ACadSharp. I have verified that the files can be read by AutoCAD and BricsCad .NET APIs. I have updated ACadSharp from Nuget today.

Screenshots

image

DomCR commented 10 months ago

Hi @thorster,

Debugging the file I've found that there was a wrong assignment for a block flag, I've opened a branch and apply the fix to master, I'll make a Nuget release shortly.

thorster commented 10 months ago

Excellent! I will test later today. Much apreciated 😀

thorster commented 10 months ago

The fix solved the problem. Thanks!