R12 DXF: POLYLINE/VERTEX with subclass markers dropped ("same key has already been added")

Open Beginner friendly
#1,278 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
backend, databases

Research direction

Start by reading DxfSectionReaderBase.readLegacyPolyline, readVertex, and readPolyline, which the issue identifies as the R12 parsing path. Reproduce with an AC1009 DXF containing group 100 subclass markers on POLYLINE and VERTEX records, then trace how those markers enter map.SubClasses. Done when the polyline and its vertices load without the duplicate-key exception and the markers are ignored for R12.

Written by the indexing model from the issue text.

Description

Describe the bug
A DXF read by the R12 rules ($ACADVER AC1009, or no version at all) whose POLYLINE and VERTEX records carry subclass markers loses every such polyline. IxMilia.Dxf writes 100 AcDb2dPolyline on every POLYLINE even for R12, so its R12 exports hit this.

The R12 path (readLegacyPolyline) reads the records with a map that already holds the subclass; when the record then contains 100 AcDb2dVertex (or AcDb2dPolyline), readVertex / readPolyline call map.SubClasses.Add(...) for a key that is already there, which throws ArgumentException: An item with the same key has already been added. The polyline and its vertices are dropped (measured on an R12 export of ours: 5 of 12 entities lost).

R12 has no subclass markers, so the R12 readers could ignore group 100, or use TryAdd.

To Reproduce

  1. Write an R12 DXF with IxMilia.Dxf 0.8.4 containing one 2D POLYLINE with three VERTEX records (or add 100 / AcDb2dPolyline to the POLYLINE and 100 / AcDb2dVertex to each VERTEX of any AC1009 file).
  2. new DxfReader(stream).Read().
  3. The polyline is missing from the model space and a notification is raised.

Expected behavior
The polyline is read with its vertices; the markers are ignored in R12.

Version
ACadSharp 3.8.0 (NuGet). The same code is on master (v3.8.10): DxfSectionReaderBase.readLegacyPolyline and readVertex (map.SubClasses.Add(DxfSubclassMarker.PolylineVertex, ...)).

We work around it by stripping group 100 from POLYLINE and VERTEX records of R12 files before reading.

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.