Repository navigation
DXF: an attribute's justification is read from its text groups, not its multiline header (#2255) - #2313
DXF: an attribute's justification is read from its text groups, not its multiline header (#2255)#2313francescoBV wants to merge 1 commit into
Conversation
…ts multiline header (storytold#2255) An ATTRIB's or ATTDEF's justification and alignment point come from its text groups. In its AcDbAttribute/AcDbAttributeDefinition subclass, 71, 72 and 11 are the multiline header and 73 the field length; they were read as the justification, alignment point and vertical justification (74), so a left-justified multiline attribute became centred with an alignment point, its next save moved its single-line text, and an older version saved after a 2018 save placed it elsewhere than one saved directly. A definition's field length 0 hid its vertical justification. Split out of storytold#1942; validated by jonascloud against storytold#2255 (storytold#2238 B2). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Filtered text groups and attribute parsing crates/io/src/dxf_read/text.rs, crates/io/src/dxf_read/entities.rs, crates/io/tests/it/multiline_attributes.rs, docs/file-format-parity.md |
The reader filters selected groups from the attribute subclass when building text for ATTRIB and ATTDEF. Regression coverage checks alignment, insertion point, and R2000 output across save round trips. The documentation describes text groups as the source of attribute justification. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
- DXF multiline ATTRIB changes Left to Center and shifts subsequent legacy export #2255 — Tracks multiline ATTRIB preservation, including justification and absent alignment points.
- DXF reader treats MTEXT column width as Common.ltscale (group 48 collision) #2247 — Reports multiline ATTRIB justification changing from Left to Center and a later legacy-export shift.
- DXF/DWG preservation: track 27 pending checks and round-trip follow-ups #2238 — Tracks the multiline ATTRIB preservation work and identifies B2 as pending.
Suggested reviewers: aiongg
Merge Risk: 
Minimal · up to 49bd6
-
This change makes DXF attribute justification and alignment come from the text groups. Left-justified multiline attributes should no longer be re-centered on import or save. No remaining merge-blocking risk was found.
Security architecture risk: 
Minimal · up to 49bd6
-
The change corrects attribute alignment parsing without adding an external entrypoint or changing access controls. Both attribute-reading paths use the same filtering rule, and regression assertions cover repeated saves and older-format export. No material security risk was identified in the reviewed change.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The changed input influence is confined to constructing attribute text from imported DXF tags. File-controlled values already reached these constructors before the change; the new operation filters that existing data path rather than introducing a new caller or privileged operation.
-
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 3 files. (1 skipped: 1 unsupported.)
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
…rvives a save (FF1) Entities read with extrusion (0,0,-1) (LINE, CIRCLE, ARC, ELLIPSE, LWPOLYLINE, INSERT, DIMENSION, LEADER, SOLID, TRACE) are written back in that OCS with their extrusion, the reader's inverse. A dimension still linked to the block it was read with keeps its text position and measurement; a dimension read without a measurement (group 42, kept as 0 by the reader) gets the one of its geometry. The attribute justification reader that was part of this change is now its own pull request (storytold#2313). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
austin62jake
left a comment
There was a problem hiding this comment.
Tested on Windows 10 Pro x64 (Rust 1.99.1, cargo-nextest 0.9.150) at this PR's head (49bd622). The fix works for the case in #2255, but it breaks single-line attributes from some other writers, and it no longer merges cleanly.
What works. justification_is_read_from_the_text_groups and the other multiline_attributes tests pass. The left-justified multiline attribute stays left-justified through two saves. cargo xtask ci passes all 7 steps at the PR head (2555 tests), with #2198 merged locally so the gate runs on Windows.
The problem. attrib_text_groups drops 71, 72 and 11/21/31 from every ATTRIB and ATTDEF after its AcDbAttribute / AcDbAttributeDefinition marker, not only from multiline ones. The DXF Reference's ATTRIB and ATTDEF tables list 72 (horizontal justification), 74 and 11 (alignment point) under that subclass. CADCraft writes 72 and 11 in AcDbText, but a writer that follows the table order puts them after the marker.
I read this single-line ATTRIB (no embedded MTEXT) with a temporary test:
0 ATTRIB … 100 AcDbText 10 0 20 0 30 0 40 2.5 1 VAL
100 AcDbAttribute 2 TAG 70 0 72 1 11 5 21 5 31 0
halign |
align_pt |
|
|---|---|---|
| Before this PR (d864a08) | Center |
(5, 5, 0) |
| This PR | Left |
None |
So a centred attribute from such a file opens left-justified at its insertion point, and the next save writes it there.
A possible fix. In the fixture, the multiline header (71 2, 72 1, 11) comes after the lock-position 280, just before 101 Embedded Object. Dropping 71/72/11 only when the attribute is multiline (embedded.is_some()), or only after the lock-position flag, would keep the #2255 fix and leave single-line attributes as they were. Dropping 73 after the marker looks right in both cases, since there it is the field length. A test with the single-line ATTRIB above would guard it.
Merge conflict. GitHub reports this PR as conflicting with main. git merge-tree shows conflicts in crates/io/src/dxf_read/entities.rs (main's #2239 Clippy changes touch the same lines) and docs/file-format-parity.md.
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the head of the diff: a DXF attribute's justification is read from its text groups, not from its multiline header (#2255). In an ATTRIB or ATTDEF the groups 71, 72 and the point 11 belong to the multiline header in a different meaning from their meaning in TEXT (72 is the horizontal justification in the text part, but a field in the header part), so a reader that merges them reads a wrong justification. The new attrib_text_groups takes the groups up to the AcDbAttribute or AcDbAttributeDefinition subclass marker and, after it, all but the field length (73) and the multiline header (71, 72 and the point 11). That is the right reading of the DXF reference, and the same kind of fix as cadcraft#953 for MTEXT. A test with an AutoCAD-written file with a multiline attribute is the proof. I have not run it, and no exact-head CI result exists for this head. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
* craft-dxf: model, the drawing above the tags (header, tables, blocks, layouts) Document::read indexes a tag list into header variables, table records, blocks with their entities, the ENTITIES records (a POLYLINE with its vertices, an INSERT with its attributes) and the objects, each a slice of the tag list. The typed table records, LAYOUT and DICTIONARY are made on request. Also the colour index palette, colour, lineweight and transparency values, extended data lookup and the object coordinate system. Merged from CADCraft's cadcraft-io dxf_read (5a6aa9b6) and VectorCraft's vectorcraft-cad import (566f7208). Neither app's document types appear. * craft-dxf: model entities (geometry, text, MTEXT columns, hatches, dimensions) Entity::read types an entity record: the properties every entity has, and LINE, POINT, CIRCLE, ARC, ELLIPSE, LWPOLYLINE, POLYLINE with its vertices (2D, 3D, mesh, polyface), SPLINE, RAY, XLINE, TEXT, MTEXT with columns, ATTDEF, INSERT with its attributes (multiline ones included), DIMENSION, LEADER, SOLID, TRACE, 3DFACE, HATCH (polyline and edge loops, pattern lines, seeds, gradient), VIEWPORT, IMAGE, WIPEOUT and TOLERANCE. Other types stay readable from the record's tags. model::text has the caret encoding of strings, both ways. Merged from CADCraft's cadcraft-io dxf_read (5a6aa9b6) and VectorCraft's vectorcraft-cad import (566f7208). * craft-dxf: a hatch spline edge without fit data leaves the loop's source count Before R2010 a spline edge has no 97 of its own, so the 97 after it counts the loop's source entities. It was read as the edge's fit point count and the sources were lost. * craft-dxf: model::write, a drawing as tags (R12 to 2018) Drawing::tags writes the header, classes, the nine symbol tables, blocks, entities and (R2000 and later) the dictionaries, plot style placeholder and layouts around the layers, linetypes, styles, dimension styles, blocks and entities it is given, in the model's own types. entity_tags writes one entity for a caller with its own file. Handles given with the content are kept; the rest are numbered after them. The file skeleton is VectorCraft's vectorcraft-cad writer.rs (566f7208); the MTEXT column groups are CADCraft's dxf_read/mtext_dxf.rs column_tags (5a6aa9b6). * craft-dxf: model objects (page setup, groups, image definitions, draw order, clip filters, DIMASSOC, scales, multiline styles), HELIX and dimension overrides model::objects types the OBJECTS records both readers and CADCraft's passes use: the AcDbPlotSettings groups of a LAYOUT, GROUP, IMAGEDEF, SORTENTSTABLE, SPATIAL_FILTER, DIMASSOC, SCALE and MLINESTYLE, and dim_overrides reads the DSTYLE list of a dimension's ACAD extended data. Document gains objects_of and dictionary_names (the name a dictionary lists an object under). HELIX is an entity kind, read and written. From CADCraft's cadcraft-io dxf_read/objects.rs, document.rs, dimassoc.rs, entities.rs, dxf_mline.rs, dxf_clip.rs and dxf_image.rs (5a6aa9b6). * craft-dxf: an attribute's vertical alignment is group 74, not the field length in 73 Group 73 of an ATTRIB or ATTDEF is its field length. A writer that emits it turned every attribute into another vertical alignment, since 73 was read first and 74 only in its absence. Ported from storytold/cadcraft#1591. * README: keep main's crate list after the merge * craft-dxf: read entity groups written after the entity's own subclass marker Some writers leave the AcDbEntity subclass without a layer and put its groups right after the entity's own marker. Every entity has a layer, so its absence marks that layout, and the run of AcDbEntity codes that starts after the marker is read too. The run ends at the first other code, so the entity's own groups that reuse a code (an MTEXT's 48) are not taken for it. Ported from storytold/cadcraft#2877. * craft-dxf: an attribute's justification is read from its text groups, not its multiline header A multiline ATTRIB or ATTDEF writes a header in its AcDbAttribute subclass whose 72 and 11 are not the justification and alignment point. A left-justified attribute writes no 72 of its own, so the header's was read and the attribute came out centred. The text is now read from the groups up to the attribute's subclass and, after it, from all but 71, 72, 73 and 11. Ported from storytold/cadcraft#2313. * craft-dxf: MLINE, read and written EntityKind::MLine holds the style name and handle, scale, justification, flags, start point and each vertex with its direction, miter and the 41 and 42 parameter lists of each element. Reading the 41s and 42s into the list their 74 or 75 started keeps them apart. From CADCraft's cadcraft-io dxf_mline.rs read_entity and entity_tags (5a6aa9b6). --------- Co-authored-by: Oliver Hagmann <268387159+ohagmann@users.noreply.github.com> Co-authored-by: austin62jake <340374338+austin62jake@users.noreply.github.com> Co-authored-by: Francesco BV <francesco.esposito@bvitalia.net>
* craft-dxf: model, the drawing above the tags (header, tables, blocks, layouts) Document::read indexes a tag list into header variables, table records, blocks with their entities, the ENTITIES records (a POLYLINE with its vertices, an INSERT with its attributes) and the objects, each a slice of the tag list. The typed table records, LAYOUT and DICTIONARY are made on request. Also the colour index palette, colour, lineweight and transparency values, extended data lookup and the object coordinate system. Merged from CADCraft's cadcraft-io dxf_read (5a6aa9b6) and VectorCraft's vectorcraft-cad import (566f7208). Neither app's document types appear. * craft-dxf: model entities (geometry, text, MTEXT columns, hatches, dimensions) Entity::read types an entity record: the properties every entity has, and LINE, POINT, CIRCLE, ARC, ELLIPSE, LWPOLYLINE, POLYLINE with its vertices (2D, 3D, mesh, polyface), SPLINE, RAY, XLINE, TEXT, MTEXT with columns, ATTDEF, INSERT with its attributes (multiline ones included), DIMENSION, LEADER, SOLID, TRACE, 3DFACE, HATCH (polyline and edge loops, pattern lines, seeds, gradient), VIEWPORT, IMAGE, WIPEOUT and TOLERANCE. Other types stay readable from the record's tags. model::text has the caret encoding of strings, both ways. Merged from CADCraft's cadcraft-io dxf_read (5a6aa9b6) and VectorCraft's vectorcraft-cad import (566f7208). * craft-dxf: a hatch spline edge without fit data leaves the loop's source count Before R2010 a spline edge has no 97 of its own, so the 97 after it counts the loop's source entities. It was read as the edge's fit point count and the sources were lost. * craft-dxf: model::write, a drawing as tags (R12 to 2018) Drawing::tags writes the header, classes, the nine symbol tables, blocks, entities and (R2000 and later) the dictionaries, plot style placeholder and layouts around the layers, linetypes, styles, dimension styles, blocks and entities it is given, in the model's own types. entity_tags writes one entity for a caller with its own file. Handles given with the content are kept; the rest are numbered after them. The file skeleton is VectorCraft's vectorcraft-cad writer.rs (566f7208); the MTEXT column groups are CADCraft's dxf_read/mtext_dxf.rs column_tags (5a6aa9b6). * craft-dxf: model objects (page setup, groups, image definitions, draw order, clip filters, DIMASSOC, scales, multiline styles), HELIX and dimension overrides model::objects types the OBJECTS records both readers and CADCraft's passes use: the AcDbPlotSettings groups of a LAYOUT, GROUP, IMAGEDEF, SORTENTSTABLE, SPATIAL_FILTER, DIMASSOC, SCALE and MLINESTYLE, and dim_overrides reads the DSTYLE list of a dimension's ACAD extended data. Document gains objects_of and dictionary_names (the name a dictionary lists an object under). HELIX is an entity kind, read and written. From CADCraft's cadcraft-io dxf_read/objects.rs, document.rs, dimassoc.rs, entities.rs, dxf_mline.rs, dxf_clip.rs and dxf_image.rs (5a6aa9b6). * craft-dxf: an attribute's vertical alignment is group 74, not the field length in 73 Group 73 of an ATTRIB or ATTDEF is its field length. A writer that emits it turned every attribute into another vertical alignment, since 73 was read first and 74 only in its absence. Ported from storytold/cadcraft#1591. * README: keep main's crate list after the merge * craft-dxf: read entity groups written after the entity's own subclass marker Some writers leave the AcDbEntity subclass without a layer and put its groups right after the entity's own marker. Every entity has a layer, so its absence marks that layout, and the run of AcDbEntity codes that starts after the marker is read too. The run ends at the first other code, so the entity's own groups that reuse a code (an MTEXT's 48) are not taken for it. Ported from storytold/cadcraft#2877. * craft-dxf: an attribute's justification is read from its text groups, not its multiline header A multiline ATTRIB or ATTDEF writes a header in its AcDbAttribute subclass whose 72 and 11 are not the justification and alignment point. A left-justified attribute writes no 72 of its own, so the header's was read and the attribute came out centred. The text is now read from the groups up to the attribute's subclass and, after it, from all but 71, 72, 73 and 11. Ported from storytold/cadcraft#2313. * craft-dxf: MLINE, read and written EntityKind::MLine holds the style name and handle, scale, justification, flags, start point and each vertex with its direction, miter and the 41 and 42 parameter lists of each element. Reading the 41s and 42s into the list their 74 or 75 started keeps them apart. From CADCraft's cadcraft-io dxf_mline.rs read_entity and entity_tags (5a6aa9b6). * craft-dxf: MULTILEADER and MLEADERSTYLE, read model::mleader reads a MULTILEADER by level (the entity's groups, its CONTEXT_DATA block, its leader roots and their leader lines, which reuse the same codes) into MLeader, keeping the entity's and the context's copies of a value apart, and MLEADERSTYLE into MLeaderStyle. Roots, lines, vertices and attribute values are capped as CADCraft caps them. The writer leaves a multileader out and counts it, as it does any record it has no groups for. From CADCraft's cadcraft-io dxf_mleader.rs parse (5a6aa9b6). --------- Co-authored-by: Oliver Hagmann <268387159+ohagmann@users.noreply.github.com> Co-authored-by: austin62jake <340374338+austin62jake@users.noreply.github.com> Co-authored-by: Francesco BV <francesco.esposito@bvitalia.net>
* craft-dxf: model, the drawing above the tags (header, tables, blocks, layouts) Document::read indexes a tag list into header variables, table records, blocks with their entities, the ENTITIES records (a POLYLINE with its vertices, an INSERT with its attributes) and the objects, each a slice of the tag list. The typed table records, LAYOUT and DICTIONARY are made on request. Also the colour index palette, colour, lineweight and transparency values, extended data lookup and the object coordinate system. Merged from CADCraft's cadcraft-io dxf_read (5a6aa9b6) and VectorCraft's vectorcraft-cad import (566f7208). Neither app's document types appear. * craft-dxf: model entities (geometry, text, MTEXT columns, hatches, dimensions) Entity::read types an entity record: the properties every entity has, and LINE, POINT, CIRCLE, ARC, ELLIPSE, LWPOLYLINE, POLYLINE with its vertices (2D, 3D, mesh, polyface), SPLINE, RAY, XLINE, TEXT, MTEXT with columns, ATTDEF, INSERT with its attributes (multiline ones included), DIMENSION, LEADER, SOLID, TRACE, 3DFACE, HATCH (polyline and edge loops, pattern lines, seeds, gradient), VIEWPORT, IMAGE, WIPEOUT and TOLERANCE. Other types stay readable from the record's tags. model::text has the caret encoding of strings, both ways. Merged from CADCraft's cadcraft-io dxf_read (5a6aa9b6) and VectorCraft's vectorcraft-cad import (566f7208). * craft-dxf: a hatch spline edge without fit data leaves the loop's source count Before R2010 a spline edge has no 97 of its own, so the 97 after it counts the loop's source entities. It was read as the edge's fit point count and the sources were lost. * craft-dxf: model::write, a drawing as tags (R12 to 2018) Drawing::tags writes the header, classes, the nine symbol tables, blocks, entities and (R2000 and later) the dictionaries, plot style placeholder and layouts around the layers, linetypes, styles, dimension styles, blocks and entities it is given, in the model's own types. entity_tags writes one entity for a caller with its own file. Handles given with the content are kept; the rest are numbered after them. The file skeleton is VectorCraft's vectorcraft-cad writer.rs (566f7208); the MTEXT column groups are CADCraft's dxf_read/mtext_dxf.rs column_tags (5a6aa9b6). * craft-dxf: model objects (page setup, groups, image definitions, draw order, clip filters, DIMASSOC, scales, multiline styles), HELIX and dimension overrides model::objects types the OBJECTS records both readers and CADCraft's passes use: the AcDbPlotSettings groups of a LAYOUT, GROUP, IMAGEDEF, SORTENTSTABLE, SPATIAL_FILTER, DIMASSOC, SCALE and MLINESTYLE, and dim_overrides reads the DSTYLE list of a dimension's ACAD extended data. Document gains objects_of and dictionary_names (the name a dictionary lists an object under). HELIX is an entity kind, read and written. From CADCraft's cadcraft-io dxf_read/objects.rs, document.rs, dimassoc.rs, entities.rs, dxf_mline.rs, dxf_clip.rs and dxf_image.rs (5a6aa9b6). * craft-dxf: an attribute's vertical alignment is group 74, not the field length in 73 Group 73 of an ATTRIB or ATTDEF is its field length. A writer that emits it turned every attribute into another vertical alignment, since 73 was read first and 74 only in its absence. Ported from storytold/cadcraft#1591. * README: keep main's crate list after the merge * craft-dxf: read entity groups written after the entity's own subclass marker Some writers leave the AcDbEntity subclass without a layer and put its groups right after the entity's own marker. Every entity has a layer, so its absence marks that layout, and the run of AcDbEntity codes that starts after the marker is read too. The run ends at the first other code, so the entity's own groups that reuse a code (an MTEXT's 48) are not taken for it. Ported from storytold/cadcraft#2877. * craft-dxf: an attribute's justification is read from its text groups, not its multiline header A multiline ATTRIB or ATTDEF writes a header in its AcDbAttribute subclass whose 72 and 11 are not the justification and alignment point. A left-justified attribute writes no 72 of its own, so the header's was read and the attribute came out centred. The text is now read from the groups up to the attribute's subclass and, after it, from all but 71, 72, 73 and 11. Ported from storytold/cadcraft#2313. * craft-dxf: MLINE, read and written EntityKind::MLine holds the style name and handle, scale, justification, flags, start point and each vertex with its direction, miter and the 41 and 42 parameter lists of each element. Reading the 41s and 42s into the list their 74 or 75 started keeps them apart. From CADCraft's cadcraft-io dxf_mline.rs read_entity and entity_tags (5a6aa9b6). * craft-dxf: MULTILEADER and MLEADERSTYLE, read model::mleader reads a MULTILEADER by level (the entity's groups, its CONTEXT_DATA block, its leader roots and their leader lines, which reuse the same codes) into MLeader, keeping the entity's and the context's copies of a value apart, and MLEADERSTYLE into MLeaderStyle. Roots, lines, vertices and attribute values are capped as CADCraft caps them. The writer leaves a multileader out and counts it, as it does any record it has no groups for. From CADCraft's cadcraft-io dxf_mleader.rs parse (5a6aa9b6). * craft-dxf: ACAD_TABLE and TABLESTYLE, read model::table reads an ACAD_TABLE's size, row heights, column widths and its cells (text, merge span, merged flag, text height outside the value block, alignment, text style, block) into Table, and a TABLESTYLE's margins, suppressed rows and its data, header and title cell types with their six borders into TableStyle. A size past 10,000 a side or 1,000,000 cells, or with no rows or columns, keeps nothing, and only cells the file holds are kept. The writer leaves a table out and counts it. From CADCraft's cadcraft-io dxf_read/entities.rs acad_table and dxf_table.rs read_table_style (5a6aa9b6). --------- Co-authored-by: Oliver Hagmann <268387159+ohagmann@users.noreply.github.com> Co-authored-by: austin62jake <340374338+austin62jake@users.noreply.github.com> Co-authored-by: Francesco BV <francesco.esposito@bvitalia.net>
* craft-dxf: model, the drawing above the tags (header, tables, blocks, layouts) Document::read indexes a tag list into header variables, table records, blocks with their entities, the ENTITIES records (a POLYLINE with its vertices, an INSERT with its attributes) and the objects, each a slice of the tag list. The typed table records, LAYOUT and DICTIONARY are made on request. Also the colour index palette, colour, lineweight and transparency values, extended data lookup and the object coordinate system. Merged from CADCraft's cadcraft-io dxf_read (5a6aa9b6) and VectorCraft's vectorcraft-cad import (566f7208). Neither app's document types appear. * craft-dxf: model entities (geometry, text, MTEXT columns, hatches, dimensions) Entity::read types an entity record: the properties every entity has, and LINE, POINT, CIRCLE, ARC, ELLIPSE, LWPOLYLINE, POLYLINE with its vertices (2D, 3D, mesh, polyface), SPLINE, RAY, XLINE, TEXT, MTEXT with columns, ATTDEF, INSERT with its attributes (multiline ones included), DIMENSION, LEADER, SOLID, TRACE, 3DFACE, HATCH (polyline and edge loops, pattern lines, seeds, gradient), VIEWPORT, IMAGE, WIPEOUT and TOLERANCE. Other types stay readable from the record's tags. model::text has the caret encoding of strings, both ways. Merged from CADCraft's cadcraft-io dxf_read (5a6aa9b6) and VectorCraft's vectorcraft-cad import (566f7208). * craft-dxf: a hatch spline edge without fit data leaves the loop's source count Before R2010 a spline edge has no 97 of its own, so the 97 after it counts the loop's source entities. It was read as the edge's fit point count and the sources were lost. * craft-dxf: model::write, a drawing as tags (R12 to 2018) Drawing::tags writes the header, classes, the nine symbol tables, blocks, entities and (R2000 and later) the dictionaries, plot style placeholder and layouts around the layers, linetypes, styles, dimension styles, blocks and entities it is given, in the model's own types. entity_tags writes one entity for a caller with its own file. Handles given with the content are kept; the rest are numbered after them. The file skeleton is VectorCraft's vectorcraft-cad writer.rs (566f7208); the MTEXT column groups are CADCraft's dxf_read/mtext_dxf.rs column_tags (5a6aa9b6). * craft-dxf: model objects (page setup, groups, image definitions, draw order, clip filters, DIMASSOC, scales, multiline styles), HELIX and dimension overrides model::objects types the OBJECTS records both readers and CADCraft's passes use: the AcDbPlotSettings groups of a LAYOUT, GROUP, IMAGEDEF, SORTENTSTABLE, SPATIAL_FILTER, DIMASSOC, SCALE and MLINESTYLE, and dim_overrides reads the DSTYLE list of a dimension's ACAD extended data. Document gains objects_of and dictionary_names (the name a dictionary lists an object under). HELIX is an entity kind, read and written. From CADCraft's cadcraft-io dxf_read/objects.rs, document.rs, dimassoc.rs, entities.rs, dxf_mline.rs, dxf_clip.rs and dxf_image.rs (5a6aa9b6). * craft-dxf: an attribute's vertical alignment is group 74, not the field length in 73 Group 73 of an ATTRIB or ATTDEF is its field length. A writer that emits it turned every attribute into another vertical alignment, since 73 was read first and 74 only in its absence. Ported from storytold/cadcraft#1591. * README: keep main's crate list after the merge * craft-dxf: read entity groups written after the entity's own subclass marker Some writers leave the AcDbEntity subclass without a layer and put its groups right after the entity's own marker. Every entity has a layer, so its absence marks that layout, and the run of AcDbEntity codes that starts after the marker is read too. The run ends at the first other code, so the entity's own groups that reuse a code (an MTEXT's 48) are not taken for it. Ported from storytold/cadcraft#2877. * craft-dxf: an attribute's justification is read from its text groups, not its multiline header A multiline ATTRIB or ATTDEF writes a header in its AcDbAttribute subclass whose 72 and 11 are not the justification and alignment point. A left-justified attribute writes no 72 of its own, so the header's was read and the attribute came out centred. The text is now read from the groups up to the attribute's subclass and, after it, from all but 71, 72, 73 and 11. Ported from storytold/cadcraft#2313. * craft-dxf: MLINE, read and written EntityKind::MLine holds the style name and handle, scale, justification, flags, start point and each vertex with its direction, miter and the 41 and 42 parameter lists of each element. Reading the 41s and 42s into the list their 74 or 75 started keeps them apart. From CADCraft's cadcraft-io dxf_mline.rs read_entity and entity_tags (5a6aa9b6). * craft-dxf: MULTILEADER and MLEADERSTYLE, read model::mleader reads a MULTILEADER by level (the entity's groups, its CONTEXT_DATA block, its leader roots and their leader lines, which reuse the same codes) into MLeader, keeping the entity's and the context's copies of a value apart, and MLEADERSTYLE into MLeaderStyle. Roots, lines, vertices and attribute values are capped as CADCraft caps them. The writer leaves a multileader out and counts it, as it does any record it has no groups for. From CADCraft's cadcraft-io dxf_mleader.rs parse (5a6aa9b6). * craft-dxf: ACAD_TABLE and TABLESTYLE, read model::table reads an ACAD_TABLE's size, row heights, column widths and its cells (text, merge span, merged flag, text height outside the value block, alignment, text style, block) into Table, and a TABLESTYLE's margins, suppressed rows and its data, header and title cell types with their six borders into TableStyle. A size past 10,000 a side or 1,000,000 cells, or with no rows or columns, keeps nothing, and only cells the file holds are kept. The writer leaves a table out and counts it. From CADCraft's cadcraft-io dxf_read/entities.rs acad_table and dxf_table.rs read_table_style (5a6aa9b6). * craft-dxf: renumber the handles of records kept from another file model::write::remap_handles rewrites a run of records' own handles and every pointer group (is_pointer_code: 320-369, 390-399, 480-481, 1005) through a map, writing the null handle for anything the map drops, so records a caller keeps from a file can go into raw_entities and raw_objects without colliding with what the writer numbers. From CADCraft's cadcraft-io dxf_raw.rs (5a6aa9b6), which renumbers what it keeps this way. --------- Co-authored-by: Oliver Hagmann <268387159+ohagmann@users.noreply.github.com> Co-authored-by: austin62jake <340374338+austin62jake@users.noreply.github.com> Co-authored-by: Francesco BV <francesco.esposito@bvitalia.net>
…#1011) * craft-dxf: model, the drawing above the tags (header, tables, blocks, layouts) Document::read indexes a tag list into header variables, table records, blocks with their entities, the ENTITIES records (a POLYLINE with its vertices, an INSERT with its attributes) and the objects, each a slice of the tag list. The typed table records, LAYOUT and DICTIONARY are made on request. Also the colour index palette, colour, lineweight and transparency values, extended data lookup and the object coordinate system. Merged from CADCraft's cadcraft-io dxf_read (5a6aa9b6) and VectorCraft's vectorcraft-cad import (566f7208). Neither app's document types appear. * craft-dxf: model entities (geometry, text, MTEXT columns, hatches, dimensions) Entity::read types an entity record: the properties every entity has, and LINE, POINT, CIRCLE, ARC, ELLIPSE, LWPOLYLINE, POLYLINE with its vertices (2D, 3D, mesh, polyface), SPLINE, RAY, XLINE, TEXT, MTEXT with columns, ATTDEF, INSERT with its attributes (multiline ones included), DIMENSION, LEADER, SOLID, TRACE, 3DFACE, HATCH (polyline and edge loops, pattern lines, seeds, gradient), VIEWPORT, IMAGE, WIPEOUT and TOLERANCE. Other types stay readable from the record's tags. model::text has the caret encoding of strings, both ways. Merged from CADCraft's cadcraft-io dxf_read (5a6aa9b6) and VectorCraft's vectorcraft-cad import (566f7208). * craft-dxf: a hatch spline edge without fit data leaves the loop's source count Before R2010 a spline edge has no 97 of its own, so the 97 after it counts the loop's source entities. It was read as the edge's fit point count and the sources were lost. * craft-dxf: model::write, a drawing as tags (R12 to 2018) Drawing::tags writes the header, classes, the nine symbol tables, blocks, entities and (R2000 and later) the dictionaries, plot style placeholder and layouts around the layers, linetypes, styles, dimension styles, blocks and entities it is given, in the model's own types. entity_tags writes one entity for a caller with its own file. Handles given with the content are kept; the rest are numbered after them. The file skeleton is VectorCraft's vectorcraft-cad writer.rs (566f7208); the MTEXT column groups are CADCraft's dxf_read/mtext_dxf.rs column_tags (5a6aa9b6). * craft-dxf: model objects (page setup, groups, image definitions, draw order, clip filters, DIMASSOC, scales, multiline styles), HELIX and dimension overrides model::objects types the OBJECTS records both readers and CADCraft's passes use: the AcDbPlotSettings groups of a LAYOUT, GROUP, IMAGEDEF, SORTENTSTABLE, SPATIAL_FILTER, DIMASSOC, SCALE and MLINESTYLE, and dim_overrides reads the DSTYLE list of a dimension's ACAD extended data. Document gains objects_of and dictionary_names (the name a dictionary lists an object under). HELIX is an entity kind, read and written. From CADCraft's cadcraft-io dxf_read/objects.rs, document.rs, dimassoc.rs, entities.rs, dxf_mline.rs, dxf_clip.rs and dxf_image.rs (5a6aa9b6). * craft-dxf: an attribute's vertical alignment is group 74, not the field length in 73 Group 73 of an ATTRIB or ATTDEF is its field length. A writer that emits it turned every attribute into another vertical alignment, since 73 was read first and 74 only in its absence. Ported from storytold/cadcraft#1591. * README: keep main's crate list after the merge * craft-dxf: read entity groups written after the entity's own subclass marker Some writers leave the AcDbEntity subclass without a layer and put its groups right after the entity's own marker. Every entity has a layer, so its absence marks that layout, and the run of AcDbEntity codes that starts after the marker is read too. The run ends at the first other code, so the entity's own groups that reuse a code (an MTEXT's 48) are not taken for it. Ported from storytold/cadcraft#2877. * craft-dxf: an attribute's justification is read from its text groups, not its multiline header A multiline ATTRIB or ATTDEF writes a header in its AcDbAttribute subclass whose 72 and 11 are not the justification and alignment point. A left-justified attribute writes no 72 of its own, so the header's was read and the attribute came out centred. The text is now read from the groups up to the attribute's subclass and, after it, from all but 71, 72, 73 and 11. Ported from storytold/cadcraft#2313. * craft-dxf: MLINE, read and written EntityKind::MLine holds the style name and handle, scale, justification, flags, start point and each vertex with its direction, miter and the 41 and 42 parameter lists of each element. Reading the 41s and 42s into the list their 74 or 75 started keeps them apart. From CADCraft's cadcraft-io dxf_mline.rs read_entity and entity_tags (5a6aa9b6). * craft-dxf: MULTILEADER and MLEADERSTYLE, read model::mleader reads a MULTILEADER by level (the entity's groups, its CONTEXT_DATA block, its leader roots and their leader lines, which reuse the same codes) into MLeader, keeping the entity's and the context's copies of a value apart, and MLEADERSTYLE into MLeaderStyle. Roots, lines, vertices and attribute values are capped as CADCraft caps them. The writer leaves a multileader out and counts it, as it does any record it has no groups for. From CADCraft's cadcraft-io dxf_mleader.rs parse (5a6aa9b6). * craft-dxf: ACAD_TABLE and TABLESTYLE, read model::table reads an ACAD_TABLE's size, row heights, column widths and its cells (text, merge span, merged flag, text height outside the value block, alignment, text style, block) into Table, and a TABLESTYLE's margins, suppressed rows and its data, header and title cell types with their six borders into TableStyle. A size past 10,000 a side or 1,000,000 cells, or with no rows or columns, keeps nothing, and only cells the file holds are kept. The writer leaves a table out and counts it. From CADCraft's cadcraft-io dxf_read/entities.rs acad_table and dxf_table.rs read_table_style (5a6aa9b6). * craft-dxf: renumber the handles of records kept from another file model::write::remap_handles rewrites a run of records' own handles and every pointer group (is_pointer_code: 320-369, 390-399, 480-481, 1005) through a map, writing the null handle for anything the map drops, so records a caller keeps from a file can go into raw_entities and raw_objects without colliding with what the writer numbers. From CADCraft's cadcraft-io dxf_raw.rs (5a6aa9b6), which renumbers what it keeps this way. * craft-dxf: write MULTILEADER, ACAD_TABLE, MLEADERSTYLE and TABLESTYLE model::write now writes the multileaders and tables the model reads: a MULTILEADER (2007 and later) with its context block, roots and leader lines and its entity overrides, and an ACAD_TABLE (2004 and later) with its size, row heights, column widths and cells, its group 343 naming the record of its block. Drawing gains mleader_styles and table_styles, written in the ACAD_MLEADERSTYLE and ACAD_TABLESTYLE dictionaries, and the CLASSES of all four. Groups and fixed values follow CADCraft's writer, which AutoCAD reads. MLeader also reads the context's landing gap (145) now, so it round-trips. From CADCraft's cadcraft-io dxf_mleader.rs entity_tags, dxf_write/entity.rs write_table_entity, dxf_write/objects.rs mleader_style_obj and table_style_obj, dxf_table.rs cell_type_tags and dxf_write/sections.rs write_classes (5a6aa9b6). --------- Co-authored-by: Oliver Hagmann <268387159+ohagmann@users.noreply.github.com> Co-authored-by: austin62jake <340374338+austin62jake@users.noreply.github.com> Co-authored-by: Francesco BV <francesco.esposito@bvitalia.net>
Requested by Francesco BV
Before: an ATTRIB or ATTDEF with a multiline (embedded MTEXT) part took the
AcDbAttributesubclass's multiline header (71, 72 and the point 11) and its field length (73) as the text's justification, alignment point and vertical justification. A left-justified multiline attribute was read as Center with an alignment point; its next save recomputed the single-line fallback TEXT's insertion from that justification, and an R2000 file saved after an R2018 save placed the attribute differently from one saved directly. A definition with field length 0 lost its vertical justification (74).After: an attribute's justification and alignment point come from its text groups: everything before its attribute subclass, and in the subclass everything but 71, 72, 73 and 11/21/31. Left stays Left with no alignment point, saves are stable, and the legacy fallback lands where a direct export puts it.
How:
attrib_text_groupsincrates/io/src/dxf_read/text.rsfilters the attribute's own groups beforetext_from; the ATTDEF reader and the ATTRIB reader after an INSERT both use it. The embedded MTEXT and every other field are read as before.Tests:
multiline_attributes::justification_is_read_from_the_text_groups(new): a left-justified multiline ATTRIB stays Left/Baseline with no alignment point through two saves; the ATTDEF's 74 wins over its field length 73; an R2000 export after two R2018 saves matches a direct R2000 export. It fails on main (Center, Some(110,53)).cargo test -p cadcraft-io,cargo clippy -p cadcraft-io --all-targets -- -D warnings,cargo fmt --check,xtask layers,cargo check -p cadcraft-io --target wasm32-unknown-unknown.roundtrip::dxf::extended::multiline_attributes,roundtrip::dxf::attributes::legacy_placement_is_independent_of_an_intermediate_modern_save) pass with this fix; they can be enabled here or in test(io): add independent DXF/DWG conformance and preservation matrices #2237, whichever merges second.Thanks to @jonascloud, who validated this reader fix against #2255 (tracker #2238, item B2) and wrote the regressions in #2237. This splits the attribute reader part out of #1942, which will be rebased with the rest.
🤖 Generated with Claude Code
Summary by CodeRabbit