DxfWriter: ACDSDATA schemas differ from the ones AutoCAD writes

Open
#1,354 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
51/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
backend

Research direction

Start by reproducing the mismatch with the provided C# snippet, then compare the ACDSDATA section of the generated out.dxf with samples/sample_AC1032_ascii.dxf. Trace CreateDataStorage() and CadFileDataStorage to see how schemas are built, and inspect writeAcdsSchemaRecord and the DXF schema reader for the reported lost property codes. Done when the writer preserves AutoCAD’s schema properties and embedded records, and the round trip handles them as described.

Written by the indexing model from the issue text.

Description

Hi @DomCR,

Thanks for 3.8.35. We moved to it today and the SOLID3D problem from #1342 is gone.

While checking 3DSOLID round trips we noticed that the schemas DxfWriter writes in the ACDSDATA section are not the same as the ones AutoCAD writes. It can be reproduced with the samples in the repo:

CadDocument doc = DwgReader.Read("samples/sample_AC1032.dwg");
DxfWriter.Write("out.dxf", doc, false);

Then compare the ACDSDATA section of out.dxf with samples/sample_AC1032_ascii.dxf, written by AutoCAD. With 3.8.35:

  1. AcDb_Thumbnail_Schema has a third property, AcDbDs::TreatedAsObjectData (280 1, 91 1). AutoCAD writes only AcDbDs::ID and Thumbnail_Data, and puts TreatedAsObjectData in an embedded record.
  2. AcDbDs::HandleAttributeSchema is written with 280 1 / 91 0. AutoCAD writes 280 7 / 91 1 / 284 1.
  3. AcDb_Thumbnail_Schema and AcDb3DSolid_ASM_Data have no embedded records. AutoCAD writes four in each (101 ACDSRECORD): TreatedAsObjectData, Legacy, AcDs:Indexable and HandleAttribute.
  4. The schemas read from the file are not used: CreateDataStorage() always builds the six fixed schemas of CadFileDataStorage, so writeAcdsSchemaRecord, which throws NotImplementedException, is never reached.

The first schema, AutoCAD on the left and DxfWriter on the right:

ACDSSCHEMA                         ACDSSCHEMA
 90 0                               90 0
 1 AcDb_Thumbnail_Schema            1 AcDb_Thumbnail_Schema
 2 AcDbDs::ID                       2 AcDbDs::ID
 280 10                             280 10
 91 8                               91 8
 2 Thumbnail_Data                   2 Thumbnail_Data
 280 15                             280 15
 91 0                               91 0
 101 ACDSRECORD                     2 AcDbDs::TreatedAsObjectData
 95 0                               280 1
 90 2                               91 1
 2 AcDbDs::TreatedAsObjectData
 280 1
 291 1
 (3 more embedded records)

A side note: when reading a DXF, consecutive schema properties get merged (Thumbnail_Data ends up inside AcDbDs::ID), and the 1, 282 and 284 codes are lost.

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.