Repository navigation
DXF: write extended data of polylines and inserts with attributes before their sub-entities - #1336
Open
SolidRockProgrammer wants to merge 2 commits into
Open
SolidRockProgrammer wants to merge 2 commits into
SolidRockProgrammer wants to merge 2 commits into
Conversation
This branch has not been deployed
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.
Description
DxfSectionWriterBase.writeEntitywrites an entity's extended data at the end, after the entity-specific writer has returned. For a heavy polyline (Polyline2D,Polyline3D,PolyfaceMesh,PolygonMesh) and for anInsertwith attributes, that writer has already written the VERTEX / ATTRIB entities and the SEQEND. So the owner's1001groups end up after the SEQEND's group 8, and a DXF reader attaches them to the SEQEND, the entity they follow. ACadSharp's ownDxfReaderdoes this. The owner loses its xdata. DWG output is not affected.Example of what was written (abridged):
writeInsertalready had a//WARNING: Write extended data before attributescomment for this case.Fix:
writePolylinewrites the polyline's extended data after group 210, before the vertices.writeInsertwrites it before the attributes, in place of the warning comment.writeEntityskips its trailingwriteExtendedDatafor those two cases.The check names the four heavy polyline types rather than
IPolyline, on purpose.LwPolylineimplementsIPolylinetoo, but it has no sub-entities and still needs its xdata written at the end. My first version usedIPolylineand dropped every LWPOLYLINE's xdata. No existing test covered that, so the suite stayed green. The newEntityWithoutSubEntitiesKeepsItsXDatatest covers it now.Tasks done in this PR
Tests:
ACadSharp.Tests/IO/SubEntityXDataTests.cs(8 cases):Polyline2Dwith xdata, AC1015 and AC1032: the1001group comes before the firstVERTEXin the written text, and afterDxfReader.Readthe xdata is on the polyline, not on its vertices or SEQEND.Insertwith an attribute, AC1015 and AC1032: the same checks againstATTRIB.Polyline3D: the same.Insertwithout attributes, anLwPolylineand aLinekeep their xdata.Before the fix, 4 of the original 5 cases fail, e.g. "the owner's xdata (line 1044) is written after its first VERTEX (line 932)". With the check widened to
IPolyline, the LWPOLYLINE case fails ("LWPOLYLINE lost its SUBENTITY_XDATA_TEST xdata"). On this branch,SubEntityXDataTestsand the existingXDataTestspass on net9.0. The full suite was run on the same change applied to v3.8.0, and nothing new failed.WriterSingleObjectTestswas not run, because some of its cases already fail on v3.8.0 itself.Minimal reproduction:
Related Issues / Pull Requests
Notes for reviewer
IPolylineto the heavy polyline types. Feel free to squash.