Cannot read with AcadSharp dwg file created with AcadSharp
See original GitHub issueDescribe the bug Cannot read with AcadSharp a dwg file written with AcadSharp.
To Reproduce
I’ve created a dwg file with AcadSharp and then saved.
All the documents section (such as the Header) are as default.
When I try to load the file with DwgReader
it throws the following exception:
ACadSharp.Exceptions.DwgNotSupportedException: 'Dwg version not recognised
.
Write dwg code:
// new document
ACadSharp.CadDocument doc = new ACadSharp.CadDocument();
// write file
ACadSharp.IO.DwgWriter writer = new ACadSharp.IO.DwgWriter("Test.dwg", doc);
writer.Write();
Read dwg code:
ACadSharp.CadDocument loaded = ACadSharp.IO.DwgReader.Read("Test.dwg");
Full exception and stack trace:
ACadSharp.Exceptions.DwgNotSupportedException: 'Dwg version not recognised
at ACadSharp.IO.DWG.DwgFileHeader.CreateFileHeader(ACadVersion version) in C:\Users\stage1\source\repos\ACadSharp\ACadSharp\IO\DWG\FileHeaders\DwgFileHeader.cs:line 37
at ACadSharp.IO.DwgReader.readFileHeader() in C:\Users\stage1\source\repos\ACadSharp\ACadSharp\IO\DWG\DwgReader.cs:line 225
at ACadSharp.IO.DwgReader.Read() in C:\Users\stage1\source\repos\ACadSharp\ACadSharp\IO\DWG\DwgReader.cs:line 97
at ACadSharp.IO.DwgReader.Read(String filename, DwgReaderConfiguration configuration, NotificationEventHandler notification) in C:\Users\stage1\source\repos\ACadSharp\ACadSharp\IO\DWG\DwgReader.cs:line 83
at ACadSharp.IO.DwgReader.Read(String filename, NotificationEventHandler notification) in C:\Users\stage1\source\repos\ACadSharp\ACadSharp\IO\DWG\DwgReader.cs:line 66
Expected behavior No exception
Screenshots
From CadUtils:
It return
AcadVersion.Unknown
Issue Analytics
- State:
- Created 6 months ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
DomCR/ACadSharp: C# library to read/write cad files like ...
C# library to read/write cad files like dxf/dwg. Contribute to DomCR/ACadSharp development by creating an account on GitHub.
Read more >Free .NET Library for AutoCAD DXF & DWG Reading & Writing
ACadSharp – A powerful Open Source C# .NET Library allows software developers to open, read and write AutoCAD DXF & DWG drawings via...
Read more >ACadSharp 1.0.1-alpha
C# library to read/write cad files like dxf/dwg. Compatible Dwg versions: DWG Release 1.1; DWG Release 1.2; DWG Release 1.4; DWG Release 2.0...
Read more >"Value does not exist" (WW CadLib)
I have this code to try and read a DWG file into memory, so that I can read and manipulate the data. I...
Read more >"DWG is currently in use or is read-only" when opening a ...
As a work-around, create a new folder and copy the DWG files into it, or resave the files into a new folder from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
perfect, I’ll open a branch to apply a fix to manually dispose the stream to avoid this issue in the future.
Well… yes, that worked, thank you 😃
This also solves the issue that the stream wasn’t closed successfully and the file resulted opened by another process, if I tried to open if after the write. Closing the program closed the stream too so the file was openable.