Skip to content

Fix DXF reader dropping AcDbPolyline subclass fields (LWPOLYLINE flags/elevation) - #6

Open
kretz wants to merge 1 commit into
node-projects:masterfrom
kretz:fix/lwpolyline-metadata
Open

Fix DXF reader dropping AcDbPolyline subclass fields (LWPOLYLINE flags/elevation)#6
kretz wants to merge 1 commit into
node-projects:masterfrom
kretz:fix/lwpolyline-metadata

Conversation

@kretz

@kretz kretz commented Aug 10, 2026

Copy link
Copy Markdown

Fixes #5

Problem

LwPolyline has no entry in src/Metadata/LookupTables/Entities.ts, so DxfMap.create(LwPolyline) produced a map with no AcDbPolyline subclass. Every group code that _readLwPolyline delegates to tryAssignCurrentValue was therefore discarded silently:

  • 70flags / isClosed
  • 38elevation
  • 39thickness
  • 43constantWidth
  • 210/220/230normal

Vertices parsed fine because the reader handles codes 10/20/40/41/42/50/91 explicitly.

Fix

Added the missing LwPolylineAcDbPolyline metadata entry, matching the shape of neighbouring entries (e.g. Line, Circle). No reader/writer changes needed — the DXF writer already writes these codes explicitly, and the DWG reader decodes them from the bitstream directly, so both were unaffected.

Test

ReadLwPolylineSubclassFields in tests/IO/DXF/DxfReader.test.ts builds a minimal ASCII DXF with a closed LWPOLYLINE (70=1, 38=5, 39=2, 43=0.5) and asserts all four round-trip. It fails before this change and passes after.

tsc --noEmit clean, full suite: 463 passed / 6 skipped.

Related, not included

The same metadata gap exists for old-style POLYLINE: there are no entries for Polyline (the abstract base), Polyline2D or Polyline3D. Consequences:

  • DxfClassMap.create(Polyline2D) / (Polyline3D) in _readPolylineCodes (DxfSectionReaderBase.ts:1098) throws "Polyline2D is not a DXF subclass", which failsafe swallows as an An error occurred while assigning a property using mapper notification — so the subclass map is never registered and the fields fall back to constructor defaults.
  • PolyfaceMesh / PolygonMesh do have entries, but their base chain dead-ends at the missing Polyline entry, so they only pick up their own codes and lose the inherited Polyline ones (flags 70, elevation 30, thickness 39, default widths 40/41, normal 210).

Left out to keep this PR scoped to the reported issue — happy to follow up here or in a separate PR, whichever you prefer.

🤖 Generated with Claude Code

LwPolyline had no entry in the entity metadata lookup table, so the
AcDbPolyline subclass map was empty and the fallback assignment in
_readLwPolyline silently discarded flags (70), elevation (38),
thickness (39), constant width (43) and normal (210/220/230).

Fixes node-projects#5

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DXF reader silently drops AcDbPolyline-subclass fields (LWPOLYLINE flags/closed, elevation) — no metadata entries for that subclass

1 participant