DWG write at AC1015/AC1018/AC1024/AC1027 requires AutoCAD recovery on a no-op round-trip (AC1032 is clean; AC1021 throws)
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with DwgWriter.getFileHeaderWriter(), DwgFileHeaderWriterAC18, and the version conditionals in DwgSectionIO; compare section layouts for native files at each affected version. Validate round-trips in GUI AutoCAD, since accoreconsole.exe silently recovers the output. Done means supported versions open without recovery and AC1021 write support is clarified or implemented.
Written by the indexing model from the issue text.
Description
Summary
A no-op round-trip (read → write, no modification) produces DWG files that AutoCAD reports as needing recovery for every version except AC1032.
| Source version | DwgWriter.Write result |
AutoCAD |
|---|---|---|
| AC1015 (2000) | writes | "needs recovery" |
| AC1018 (2004) | writes | "needs recovery" |
| AC1021 (2007) | throws CadNotSupportedException |
— |
| AC1024 (2010) | writes | "needs recovery" |
| AC1027 (2013) | writes | "needs recovery" |
| AC1032 (2018) | writes | opens clean |
The file is not destroyed — AutoCAD's recovery succeeds and the drawing is usable afterwards. But every delivered file shows the recovery prompt, which is a blocker for batch processing.
Minimal reproduction
No proprietary files needed — any drawing works:
- In AutoCAD, create a drawing with a few TEXT and MTEXT entities.
SAVEAS→ 2010 (AC1024). - Round-trip it, touching nothing:
var doc = DwgReader.Read("in.dwg"); // version = AC1024
DwgWriter.Write("out.dwg", doc, new DwgWriterConfiguration());
- Open
out.dwgin AutoCAD (GUI). It prompts to recover. - Repeat with the same drawing saved as 2000 / 2004 / 2013 / 2018 — only the 2018 output opens without the prompt.
Expected: a no-op round-trip at any supported version produces a file AutoCAD opens without recovery.
Related observation: AC1021 cannot be written at all
DwgWriter.getFileHeaderWriter() has:
case ACadVersion.AC1021:
throw new CadNotSupportedException(this._document.Header.Version);
Is this a permanent limitation or just not implemented yet? Writing AC1021 would fail even for a no-op round-trip, which makes the version ladder (R2000–R2018) incomplete on the write side.
Why this is easy to miss when testing
accoreconsole.exe silently performs the recovery and returns exit code 0, so a CLI-based round-trip test looks completely clean:
accoreconsole /i out.dwg /s script.scr → rc = 0, script runs normally
The problem only shows up in GUI AutoCAD, where the recovery prompt appears. Anyone validating writes headlessly (as I was) will conclude the output is fine.
Workaround I'm using
Forcing the header version before writing makes the output clean, because it stays on the AC1032 path and never enters the downgrade branches:
doc.Header.Version = ACadVersion.AC1032;
DwgWriter.Write(path, doc, config);
All of 2000/2004/2007/2010/2013 then write successfully and open clean — including AC1021, which no longer hits the throw. Side effect is that output is always 2018, which is not acceptable if downstream still uses older AutoCAD — hence this issue.
Guess at the cause
DwgFileHeaderWriterAC18 is shared by AC1018/AC1024/AC1027/AC1032 and looks like it's implemented against the 2018 layout, with DwgSectionIO's R2004Plus / R2007Plus / R2010Plus / R2013Plus / R2018Plus flags doing the subtraction for older targets. If any one of those conditionals is inverted or missing, the section layout ends up inconsistent with the version string in the header — which is exactly the kind of thing AutoCAD's recovery fixes quietly.
I haven't been able to narrow it to a specific field; that would need a section-by-section diff against a native file at each version.
Happy to test patches or provide more detail.
- Dominant language
- C#
- Stars
- 873
- Forks
- 223
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 28
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DomCR/ACadSharp
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
-
DWG writer: text styles get the text-style table as their xref block handlePossibly taken @menes97 claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 81/100
Maintainers usually reply within 3 days
-
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 3 days
-
DwgWriter writes a null shape-file handle for SHAPE entities (WriteShapes = true)Possibly taken @menes97 claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
-
DwgReader reads a color-book entity's Color as ByBlock instead of the book's colorPossibly taken @menes97 claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
Similar issues
-
hand-to-AI
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
CactuseSecurity/firewall-orchestrator#5803 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
bug python
Difficulty 1/5 Under an hour Newbie friendliness 88/100
ilia-sokolov/OfficeAgent.NET#89 ·
Maintainers usually reply within 13 days