Fix DXF reader dropping AcDbPolyline subclass fields (LWPOLYLINE flags/elevation) - #6
Open
kretz wants to merge 1 commit into
Open
Fix DXF reader dropping AcDbPolyline subclass fields (LWPOLYLINE flags/elevation)#6kretz wants to merge 1 commit into
kretz wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5
Problem
LwPolylinehas no entry insrc/Metadata/LookupTables/Entities.ts, soDxfMap.create(LwPolyline)produced a map with noAcDbPolylinesubclass. Every group code that_readLwPolylinedelegates totryAssignCurrentValuewas therefore discarded silently:70—flags/isClosed38—elevation39—thickness43—constantWidth210/220/230—normalVertices parsed fine because the reader handles codes 10/20/40/41/42/50/91 explicitly.
Fix
Added the missing
LwPolyline→AcDbPolylinemetadata 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
ReadLwPolylineSubclassFieldsintests/IO/DXF/DxfReader.test.tsbuilds 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 --noEmitclean, full suite: 463 passed / 6 skipped.Related, not included
The same metadata gap exists for old-style
POLYLINE: there are no entries forPolyline(the abstract base),Polyline2DorPolyline3D. Consequences:DxfClassMap.create(Polyline2D)/(Polyline3D)in_readPolylineCodes(DxfSectionReaderBase.ts:1098) throws"Polyline2D is not a DXF subclass", whichfailsafeswallows as anAn error occurred while assigning a property using mappernotification — so the subclass map is never registered and the fields fall back to constructor defaults.PolyfaceMesh/PolygonMeshdo have entries, but their base chain dead-ends at the missingPolylineentry, so they only pick up their own codes and lose the inheritedPolylineones (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