Commit Graph
12 Commits
Author SHA1 Message Date
228f6d0c50 craft-dxf: write MULTILEADER, ACAD_TABLE, MLEADERSTYLE and TABLESTYLE (#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>
2026-11-11 22:12:08 -05:00
b15cd61ab6 craft-dxf: renumber the handles of records kept from another file (#997)
* 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>
2026-11-11 22:08:25 -05:00
5f3d3d0326 craft-dxf: ACAD_TABLE and TABLESTYLE (read) (#994)
* 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>
2026-11-11 22:08:03 -05:00
838add7b8e craft-dxf: MULTILEADER and MLEADERSTYLE (read) (#986)
* 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>
2026-11-11 22:00:31 -05:00
83c654d2a9 craft-dxf: model reader fixes from open CADCraft PRs; MLINE (#981)
* 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>
2026-11-11 21:47:41 -05:00
Dylan M. Taylor b85549a5b4 craft-dxf: model objects (page setup, GROUP, IMAGEDEF, SORTENTSTABLE, SPATIAL_FILTER, DIMASSOC, SCALE, MLINESTYLE), HELIX, dimension overrides (#955)
* 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).

* README: keep main's crate list after the merge
2026-11-11 20:50:47 -05:00
Dylan M. Taylor 491fb0095f craft-dxf: model::write, a drawing as tags (R12 to 2018) (#947)
* 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).

* README: keep main's crate list after the merge
2026-11-11 20:03:30 -05:00
Dylan M. Taylor e0a3b2b8c4 craft-dxf: model entities (geometry, text, MTEXT columns, hatches, dimensions) (#927)
* 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.

* README: keep main's crate list after the merge
2026-11-11 19:21:50 -05:00
Dylan M. Taylor 00c8771f0c craft-dxf: model, the drawing above the tags (header, tables, blocks, layouts) (#926)
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.
2026-11-11 18:41:57 -05:00
64a8c7f74c craft-dxf: faster ASCII writing and parse_recovering (ports of open CADCraft PRs) (#924)
* dxf: write group codes, reals and plain text without the formatting machinery

write_ascii and its code page forms wrote every group code through
write!("{:>3}"), every real through a String of its own and every string
character by character. A large drawing writes millions of each. Codes 0 to
9999 and reals are now appended in place, and text with no line break or
backslash that is ASCII (or goes out as UTF-8) is copied as it is. Text for a
code page still takes the long path, since a code page may write an ASCII
character another way. The output is byte for byte what it was.

Ported from storytold/cadcraft#1938 (the crates/dxf part).

* dxf: parse_recovering reads a damaged or truncated ASCII file up to the damage

parse fails a file at the first line that is no group code, and at a last
group code with no value. parse_recovering returns the tags before that point
and the line where reading stopped, so a caller can open what the file still
holds and say where it ends. Reading stops at the damage: lines after it are
not paired up by guesswork. Damage before the first group, a truncated binary
file and the group-code limit are still errors.

section_slices ends a section at EOF as well as ENDSEC, so the EOF of a file
cut inside a section is not one of that section's records.

Ported from storytold/cadcraft#1565 (the crates/dxf part).

---------

Co-authored-by: Francesco BV <francesco.esposito@bvitalia.net>
Co-authored-by: Alex Ortiz <76929676+aljormon84@users.noreply.github.com>
2026-11-11 18:41:05 -05:00
ebb40fa0c9 craft-dxf: R12 binary, more code pages, borrowing sections, exponent reals (ports of open CadCraft PRs) (#847)
* craft-dxf: the ASCII reader unescapes only text that holds a backslash

Only a string with a backslash can hold a \U+ or \M+ escape; every other
string moves into the tag as it is instead of being copied. The EOF check
reads the value before it moves.

Ported from storytold/cadcraft#1833.

* craft-dxf: write_ascii_in_page writes the code page without the UTF-8 fallback

write_ascii_in falls back to pure ASCII when the code page bytes happen to
be valid UTF-8, for readers that guess UTF-8. A reader that decodes a
pre-2007 DXF strictly by its $DWGCODEPAGE needs the code page bytes.

Ported from storytold/cadcraft#2851.

* craft-dxf: behaviour-preserving cleanups

Exact group-code mappings in one place, documented errors on the fallible
public parsers, and simpler option, result and formatting idioms. No change
to parsing, writing, numeric conversion, encoding or the public API.

Ported from storytold/cadcraft#2571.

* craft-dxf: read R12 and earlier binary DXF (1-byte group codes)

Binary DXF written before R13 stores each group code in one byte, with 255
escaping a 2-byte code. The reader only knew the R13+ layout, where codes
are two bytes, and also treated 255 as an escape there. The layout is now
told from the first tag; 255 is an escape only in the 1-byte layout and an
ordinary code in R13+.

Ported from storytold/cadcraft#1499.

* craft-dxf: section_slices, record_slices and Tag::str_ref borrow instead of copying

sections() and records() copy every tag out of the parsed list, so a reader
that keeps the list holds a large file's tags two or three times. The new
functions return slices of the list. sections() and records() now build
their copies from them, so there is one implementation of each split.

Ported from storytold/cadcraft#1708. storytold/cadcraft#1588 solves the same
problem by changing Section itself; this keeps the existing API.

* craft-dxf: reals beyond 1e16 or below 1e-10 are written in exponent form; string_groups

format_real wrote f64::MAX as 309 digits. Values outside 1e-10..1e16 are now
written as AutoCAD writes them (1.0E+20) and read back exactly.
string_groups splits text into the 250-character groups long strings are
stored in (MAX_STRING_CHARS).

Ported from storytold/cadcraft#1790.

* craft-dxf: DOS 720/737/775/855/857/860/861/863/864/865/869 and ISO 8859-15 code pages; cheaper unescape and hex

$DWGCODEPAGE values DOS720, 737, 775, 855, 857, 860, 861, 863, 864, 865, 869
and ISO8859_15 had no decoder and fell back to Windows-1252. ISO 8859-15
decodes through encoding_rs, the DOS pages through tables checked against
the Unicode Consortium mapping files (dos_tables.rs). DOS 864's byte 0x25 is
U+066A, so a writer escapes '%' there. U+FFFD is never written as a table
byte. A string without an escape moves into its tag without a copy, cstr
finds its terminator with one scan, and binary chunks are hex-encoded from a
table.

Ported from storytold/cadcraft#1271. Its group-code-255 change is carried by
the R12 binary port: the 1-byte layout is detected only when the escaped
code is one that needs the escape, so an R13+ file starting with code 255
still reads.

* craft-dxf: Korean Johab (ANSI_1361) text and \M+4 escapes decode

Johab had no decoder: files declaring ANSI_1361 were read as Windows-1252
and \M+4 escapes stayed literal. Hangul syllables are composed from the
three 5-bit jamo indices (KS X 1001 annex 3); symbols and Hanja map onto
KS X 1001 rows decoded as EUC-KR. Read only: a writer escapes instead.

Ported from storytold/cadcraft#1911 (its DOS code pages are covered by the
tables from storytold/cadcraft#1271).

---------

Co-authored-by: mo <131036780+mbolling@users.noreply.github.com>
Co-authored-by: ffishman <20211677+ffishman@users.noreply.github.com>
Co-authored-by: Cédric Legrand <cedric@legrand-tech.fr>
Co-authored-by: valentinevg812-eng <valentinevg812@gmail.com>
Co-authored-by: Mads Holten Rasmussen <mads.h.rasmussen@gmail.com>
Co-authored-by: LastSkywalker <maksim@sky-tehnol.uk>
Co-authored-by: vangel76 <vangel1976@googlemail.com>
Co-authored-by: Francesco BV <francesco.esposito@bvitalia.net>
2026-11-11 14:58:05 -05:00
Dylan M. Taylor 006e4df225 Add craft-dxf: DXF tag reader and writer, from CADCraft (#796)
Moved from cadcraft-dxf (cadcraft 2f8f1861) unchanged apart from names and docs:
ASCII and binary DXF as group-code tags, sections and entities, pre-2007
code pages, versions, and writing. VectorCraft's hand-written DXF writer
can move onto it next.

Part of #778, #791.
2026-11-10 20:25:03 -05:00