DwgWriter: AutoCAD drops a 3DSOLID written with SAT data to DWG 2000-2010

Open
#1,355 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
56/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
backend

Research direction

Read writeModelerGeometry and writeModelerGeometryData in DwgObjectWriter.Entities.cs, using #1150 and the attached failing and fixed DWG files as references. Compare the writer output with AutoCAD’s sample files and check the corresponding readModelerGeometry early return. Done means ACadSharp writes SAT solids that open in AutoCAD and can read its own output back correctly.

Written by the indexing model from the issue text.

Description

bug

When a 3DSOLID with SAT data is written to a DWG 2000-2010 file, AutoCAD (TrueView 2025) asks to recover, reports "Modeling Operation Error: Error Code Number is 58000" and the solid is gone. The same SAT written to a DXF 2010 opens fine.

Compared with the files AutoCAD writes (samples/sample_AC1014.dwg to sample_AC1024.dwg), writeModelerGeometry differs in two places:

  1. It returns right after the SAT, so the record ends at the zero block size. AutoCAD goes on with the wireframe block (the Wireframe present bit and what follows) and, from R2007, the trailing BL.
  2. It writes the whole SAT as one block. AutoCAD splits it into 4096 byte blocks.

With only the first change AutoCAD still fails. With both, and the unknown bit set to 1 as AutoCAD does for SAT, the file opens and the solid is there. readModelerGeometry has the same early return, so ACadSharp reads its own files back without noticing.

#1150 writes the record this way (writeModelerGeometry and writeModelerGeometryData in DwgObjectWriter.Entities.cs), in case it helps as a reference.

Attached: box_AC1024_3.8.35.dwg, written with 3.8.35 (fails), and box_AC1024_fixed.dwg, the same document with the changes above (opens). The box SAT comes from samples/sample_AC1015.dwg.

box_AC1024_58000.zip

Dominant language
C#
Stars
873
Forks
223
Avg merge
1d 15h
Merged PRs (30d)
28

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DomCR/ACadSharp

All issues in DomCR/ACadSharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.