@linkiez/dxf-renew 7.1.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/.eslintrc.json +1 -16
  2. package/.yarn/install-state.gz +0 -0
  3. package/ARCHITECTURE.md +163 -0
  4. package/CHANGELOG.md +16 -0
  5. package/README.md +72 -10
  6. package/{PLAN.md → ROADMAP.md} +227 -35
  7. package/dist/dxf.js +1090 -344
  8. package/docs/FIXTURE_VALIDATION_EZDXF.md +1 -1
  9. package/lib/Helper.cjs +4 -0
  10. package/lib/Helper.cjs.map +3 -3
  11. package/lib/Helper.js +4 -0
  12. package/lib/Helper.js.map +2 -2
  13. package/lib/entityToPolyline.cjs +95 -0
  14. package/lib/entityToPolyline.cjs.map +3 -3
  15. package/lib/entityToPolyline.js +95 -0
  16. package/lib/entityToPolyline.js.map +2 -2
  17. package/lib/handlers/entities.cjs +22 -2
  18. package/lib/handlers/entities.cjs.map +3 -3
  19. package/lib/handlers/entities.js +22 -2
  20. package/lib/handlers/entities.js.map +2 -2
  21. package/lib/handlers/entity/mleader.cjs +69 -0
  22. package/lib/handlers/entity/mleader.cjs.map +7 -0
  23. package/lib/handlers/entity/mleader.js +34 -0
  24. package/lib/handlers/entity/mleader.js.map +7 -0
  25. package/lib/handlers/entity/mline.cjs +91 -0
  26. package/lib/handlers/entity/mline.cjs.map +7 -0
  27. package/lib/handlers/entity/mline.js +56 -0
  28. package/lib/handlers/entity/mline.js.map +7 -0
  29. package/lib/handlers/entity/oleframe.cjs +98 -0
  30. package/lib/handlers/entity/oleframe.cjs.map +7 -0
  31. package/lib/handlers/entity/oleframe.js +63 -0
  32. package/lib/handlers/entity/oleframe.js.map +7 -0
  33. package/lib/handlers/entity/ray.cjs +81 -0
  34. package/lib/handlers/entity/ray.cjs.map +7 -0
  35. package/lib/handlers/entity/ray.js +46 -0
  36. package/lib/handlers/entity/ray.js.map +7 -0
  37. package/lib/handlers/entity/region.cjs +67 -0
  38. package/lib/handlers/entity/region.cjs.map +7 -0
  39. package/lib/handlers/entity/region.js +32 -0
  40. package/lib/handlers/entity/region.js.map +7 -0
  41. package/lib/handlers/entity/shape.cjs +95 -0
  42. package/lib/handlers/entity/shape.cjs.map +7 -0
  43. package/lib/handlers/entity/shape.js +60 -0
  44. package/lib/handlers/entity/shape.js.map +7 -0
  45. package/lib/handlers/entity/table.cjs +71 -0
  46. package/lib/handlers/entity/table.cjs.map +7 -0
  47. package/lib/handlers/entity/table.js +36 -0
  48. package/lib/handlers/entity/table.js.map +7 -0
  49. package/lib/handlers/entity/trace.cjs +101 -0
  50. package/lib/handlers/entity/trace.cjs.map +7 -0
  51. package/lib/handlers/entity/trace.js +66 -0
  52. package/lib/handlers/entity/trace.js.map +7 -0
  53. package/lib/handlers/entity/wipeout.cjs +122 -0
  54. package/lib/handlers/entity/wipeout.cjs.map +7 -0
  55. package/lib/handlers/entity/wipeout.js +87 -0
  56. package/lib/handlers/entity/wipeout.js.map +7 -0
  57. package/lib/handlers/entity/xline.cjs +81 -0
  58. package/lib/handlers/entity/xline.cjs.map +7 -0
  59. package/lib/handlers/entity/xline.js +46 -0
  60. package/lib/handlers/entity/xline.js.map +7 -0
  61. package/lib/handlers/objects.cjs +43 -1
  62. package/lib/handlers/objects.cjs.map +2 -2
  63. package/lib/handlers/objects.js +43 -1
  64. package/lib/handlers/objects.js.map +2 -2
  65. package/lib/handlers/tables.cjs +96 -17
  66. package/lib/handlers/tables.cjs.map +2 -2
  67. package/lib/handlers/tables.js +96 -17
  68. package/lib/handlers/tables.js.map +2 -2
  69. package/lib/index.cjs +5 -2
  70. package/lib/index.cjs.map +3 -3
  71. package/lib/index.js +18 -16
  72. package/lib/index.js.map +3 -3
  73. package/lib/toJson.cjs +29 -0
  74. package/lib/toJson.cjs.map +7 -0
  75. package/lib/toJson.js +9 -0
  76. package/lib/toJson.js.map +7 -0
  77. package/lib/toSVG.cjs +34 -3
  78. package/lib/toSVG.cjs.map +2 -2
  79. package/lib/toSVG.js +34 -3
  80. package/lib/toSVG.js.map +2 -2
  81. package/lib/types/entity.cjs.map +1 -1
  82. package/lib/types/helper.cjs.map +1 -1
  83. package/lib/types/index.cjs +20 -0
  84. package/lib/types/index.cjs.map +2 -2
  85. package/lib/types/index.js +10 -0
  86. package/lib/types/index.js.map +2 -2
  87. package/lib/types/mleader-entity.cjs +17 -0
  88. package/lib/types/mleader-entity.cjs.map +7 -0
  89. package/lib/types/mleader-entity.js +1 -0
  90. package/lib/types/mleader-entity.js.map +7 -0
  91. package/lib/types/mline-entity.cjs +17 -0
  92. package/lib/types/mline-entity.cjs.map +7 -0
  93. package/lib/types/mline-entity.js +1 -0
  94. package/lib/types/mline-entity.js.map +7 -0
  95. package/lib/types/oleframe-entity.cjs +17 -0
  96. package/lib/types/oleframe-entity.cjs.map +7 -0
  97. package/lib/types/oleframe-entity.js +1 -0
  98. package/lib/types/oleframe-entity.js.map +7 -0
  99. package/lib/types/options.cjs.map +1 -1
  100. package/lib/types/ray-entity.cjs +17 -0
  101. package/lib/types/ray-entity.cjs.map +7 -0
  102. package/lib/types/ray-entity.js +1 -0
  103. package/lib/types/ray-entity.js.map +7 -0
  104. package/lib/types/region-entity.cjs +17 -0
  105. package/lib/types/region-entity.cjs.map +7 -0
  106. package/lib/types/region-entity.js +1 -0
  107. package/lib/types/region-entity.js.map +7 -0
  108. package/lib/types/shape-entity.cjs +17 -0
  109. package/lib/types/shape-entity.cjs.map +7 -0
  110. package/lib/types/shape-entity.js +1 -0
  111. package/lib/types/shape-entity.js.map +7 -0
  112. package/lib/types/table-entity.cjs +17 -0
  113. package/lib/types/table-entity.cjs.map +7 -0
  114. package/lib/types/table-entity.js +1 -0
  115. package/lib/types/table-entity.js.map +7 -0
  116. package/lib/types/tables.cjs.map +1 -1
  117. package/lib/types/trace-entity.cjs +17 -0
  118. package/lib/types/trace-entity.cjs.map +7 -0
  119. package/lib/types/trace-entity.js +1 -0
  120. package/lib/types/trace-entity.js.map +7 -0
  121. package/lib/types/wipeout-entity.cjs +17 -0
  122. package/lib/types/wipeout-entity.cjs.map +7 -0
  123. package/lib/types/wipeout-entity.js +1 -0
  124. package/lib/types/wipeout-entity.js.map +7 -0
  125. package/lib/types/xline-entity.cjs +17 -0
  126. package/lib/types/xline-entity.cjs.map +7 -0
  127. package/lib/types/xline-entity.js +1 -0
  128. package/lib/types/xline-entity.js.map +7 -0
  129. package/package.json +5 -19
  130. package/src/Helper.ts +6 -1
  131. package/src/entityToPolyline.ts +124 -2
  132. package/src/handlers/entities.ts +21 -1
  133. package/src/handlers/entity/mleader.ts +46 -0
  134. package/src/handlers/entity/mline.ts +74 -0
  135. package/src/handlers/entity/oleframe.ts +62 -0
  136. package/src/handlers/entity/ray.ts +52 -0
  137. package/src/handlers/entity/region.ts +42 -0
  138. package/src/handlers/entity/shape.ts +73 -0
  139. package/src/handlers/entity/table.ts +49 -0
  140. package/src/handlers/entity/trace.ts +72 -0
  141. package/src/handlers/entity/wipeout.ts +114 -0
  142. package/src/handlers/entity/xline.ts +52 -0
  143. package/src/handlers/objects.ts +64 -8
  144. package/src/handlers/tables.ts +134 -21
  145. package/src/index.ts +9 -18
  146. package/src/toJson.ts +8 -0
  147. package/src/toSVG.ts +45 -3
  148. package/src/types/entity.ts +20 -0
  149. package/src/types/helper.ts +2 -1
  150. package/src/types/index.ts +10 -0
  151. package/src/types/mleader-entity.ts +8 -0
  152. package/src/types/mline-entity.ts +12 -0
  153. package/src/types/oleframe-entity.ts +40 -0
  154. package/src/types/options.ts +7 -0
  155. package/src/types/ray-entity.ts +12 -0
  156. package/src/types/region-entity.ts +11 -0
  157. package/src/types/shape-entity.ts +19 -0
  158. package/src/types/table-entity.ts +14 -0
  159. package/src/types/tables.ts +76 -0
  160. package/src/types/trace-entity.ts +14 -0
  161. package/src/types/wipeout-entity.ts +20 -0
  162. package/src/types/xline-entity.ts +12 -0
  163. package/docs/DIMENSION_SUMMARY.md +0 -254
  164. package/docs/DXF_VERSION_SUPPORT.md +0 -45
  165. package/docs/ENTITY_SVG_ROADMAP.md +0 -96
  166. package/docs/IMPLEMENTED-2D-ENTITIES.md +0 -54
  167. package/docs/README.md +0 -22
  168. package/docs/SVG_RENDERING_INTEGRATION_TESTS.md +0 -119
  169. package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.md +0 -241
@@ -1,96 +0,0 @@
1
- # Entity SVG Roadmap (Fixture → ezdxf → SVG Integration)
2
-
3
- This roadmap is a **repeatable checklist** for each DXF entity:
4
-
5
- 1. Confirm/produce a fixture in `test/resources/`
6
- 2. Validate it with ezdxf
7
- 3. Add/extend unit parsing tests
8
- 4. Add final SVG integration tests
9
-
10
- The goal is incremental coverage: one entity at a time, with fixtures and tests proving end-to-end behavior.
11
-
12
- ## Template (Use For Every Entity)
13
-
14
- ### 1) Fixture
15
-
16
- - Add or pick a DXF fixture in `test/resources/<entity>-<scenario>.dxf`.
17
- - Keep fixtures minimal: only the needed sections/entities.
18
-
19
- ### 2) ezdxf validation
20
-
21
- - Run `yarn validate:fixtures`
22
- - Confirm:
23
- - The file loads in ezdxf
24
- - `$ACADVER` is present and sane
25
- - Entity type counts include your target entity
26
-
27
- ### 3) Unit tests
28
-
29
- - Add unit parsing tests under `test/unit/`.
30
- - Assert minimum required fields for the entity type.
31
-
32
- ### 4) SVG integration tests
33
-
34
- - Add `test/integration-browser/<entity>-rendering.browser.spec.js`.
35
- - Assert:
36
- - `<svg ...>` envelope
37
- - `viewBox="..."`
38
- - Required SVG elements exist
39
- - Key attributes exist (markers, transforms, href, etc)
40
- - Expected text content (when applicable)
41
-
42
- #### Saved PNG per entity (required)
43
-
44
- Every browser integration test should save a screenshot to `test/rendered/` for manual review.
45
-
46
- - Use deterministic naming tied to the fixture: `test/rendered/<fixture-name>.png`
47
- - Overwrite is expected (re-running tests updates the same file).
48
-
49
- See: `docs/SVG_RENDERING_INTEGRATION_TESTS.md` (Saved Render Artifacts section)
50
-
51
- ## DIMENSION (Start Here)
52
-
53
- ### Fixture(s)
54
-
55
- - `test/resources/dimension-vertical.dxf`
56
- - `test/resources/dimensions.dxf` (optional secondary)
57
-
58
- ### ezdxf validation
59
-
60
- - Run `yarn validate:fixtures`
61
- - Confirm `dimension-vertical.dxf` includes `DIMENSION` in modelspace.
62
-
63
- ### Unit tests
64
-
65
- Already present:
66
-
67
- - `test/unit/dimensions.test.js`
68
-
69
- ### SVG integration test
70
-
71
- Implemented:
72
-
73
- - `test/integration-browser/dimension-rendering.browser.spec.js`
74
-
75
- Assertions:
76
-
77
- - Marker definitions exist (prefix-based regex)
78
- - Dimension line references `marker-start` and `marker-end`
79
- - Dimension text appears in the SVG (`5.35`)
80
-
81
- ## Next Entities (Suggested Order)
82
-
83
- This order prioritizes entities already in the codebase and/or those that tend to break rendering pipelines.
84
-
85
- 1. TEXT
86
- 2. MTEXT
87
- 3. LEADER
88
- 4. TOLERANCE
89
- 5. IMAGE / IMAGEDEF
90
- 6. UNDERLAY (DWF/DGN/PDF underlay entities)
91
- 7. INSERT (block expansion)
92
- 8. HATCH
93
- 9. LWPOLYLINE / POLYLINE
94
- 10. SPLINE
95
-
96
- For each, create at least one “single entity” fixture and one “mixed scene” fixture.
@@ -1,54 +0,0 @@
1
- # List of DXF 2D Entities
2
-
3
- This list was generated based on the AutoCAD 2012 DXF reference documentation. It catalogs 2D entities, indicating whether they have already been implemented in this project.
4
-
5
- | Entity | Implemented | Description |
6
- | :--- | :---: | :--- |
7
- | **ARC** | ✅ | A circular arc. |
8
- | **CIRCLE** | ✅ | A circle. |
9
- | **ELLIPSE** | ✅ | An ellipse or elliptical arc. |
10
- | **HATCH** | ✅ | Fills a bounded area with a pattern, solid color, or gradient. |
11
- | **LINE** | ✅ | A straight line segment. |
12
- | **LWPOLYLINE** | ✅ | A lightweight 2D polyline. |
13
- | **MTEXT** | ✅ | Multi-line text with advanced formatting. |
14
- | **POINT** | ✅ | A point entity. |
15
- | **POLYLINE** | ✅ | A 2D or 3D polyline (with vertices). |
16
- | **SOLID** | ✅ | A 2D area filled with solid color. |
17
- | **SPLINE** | ✅ | A spline curve. |
18
- | **TEXT** | ✅ | A single line of text. |
19
- | **DIMENSION** | ✅ | Dimension entity (linear, angular, radial, etc.). **Complete implementation**: text and styleName parsing, DIMSTYLE integration (68+ properties), rendering of 6 dimension types with extension lines, arrows, text rotation, color support (DIMCLRD, DIMCLRE, DIMCLRT) and line weights (DIMLWD, DIMLWE). See `docs/DIMENSION_IMPLEMENTATION_PLAN.md` for details. |
20
- | **INSERT** | ✅ | A block insertion (block reference). |
21
- | **ATTDEF** | ✅ | Attribute definition for a block. |
22
- | **ATTRIB** | ✅ | An attribute instance attached to a block. |
23
- | **OLE2FRAME** | ✅ | An OLE (Object Linking and Embedding) object. |
24
- | **LEADER** | ❌ | A leader line, used for annotations. Creates a line that connects the annotation to a feature in a drawing. |
25
- | **MLINE** | ❌ | A multi-line entity with parallel lines. |
26
- | **RAY** | ❌ | A semi-infinite line that extends infinitely in one direction from its start point. |
27
- | **SHAPE** | ❌ | A shape from a shape file (.shx). Inserts a named shape from a shape file that has already been loaded using the LOAD command. |
28
- | **TOLERANCE** | ❌ | A geometric tolerance. Creates geometric tolerances contained in a feature control frame. |
29
- | **TRACE** | ❌ | A solid 2D line with width. |
30
- | **WIPEOUT** | ❌ | An area that masks other objects with the background color. |
31
- | **XLINE** | ❌ | An infinite construction line. |
32
-
33
- ---
34
-
35
- ## 3D Entities (For Reference)
36
-
37
- | Entity | Implemented | Description |
38
- | :--- | :---: | :--- |
39
- | **3DFACE** | ✅ | A three-dimensional face. |
40
- | **3DSOLID** | ❌ | A 3D ACIS solid object. Displays 3D solids as wireframe or shaded objects. |
41
- | **BODY** | ❌ | A 3D ACIS body object. |
42
- | **HELIX** | ❌ | A 3D helix. |
43
- | **IMAGE** | ❌ | A raster image. |
44
- | **LIGHT** | ❌ | A light source. |
45
- | **MESH** | ❌ | A 3D mesh. |
46
- | **REGION** | ❌ | A closed 2D area (region). |
47
- | **SECTION** | ❌ | A section object. |
48
- | **SUN** | ❌ | A sun light object. |
49
- | **SURFACE** | ❌ | A 3D surface (extruded, loft, etc.). |
50
- | **TABLE** | ❌ | A table entity. |
51
- | **UNDERLAY** | ❌ | An underlay (e.g., DWF, DGN, PDF). |
52
- | **VIEWPORT** | ✅ | A viewport in paper space. |
53
-
54
- *Note: The `POLYLINE` implementation may include 3D vertices, but the entity itself is often used for 2D shapes.*
package/docs/README.md DELETED
@@ -1,22 +0,0 @@
1
- # Documentation
2
-
3
- This folder contains the project documentation. The goal is to keep docs small, focused, and non-overlapping.
4
-
5
- ## Where to Start
6
-
7
- - Entity support overview: `docs/IMPLEMENTED-2D-ENTITIES.md`
8
- - DXF version support notes: `docs/DXF_VERSION_SUPPORT.md`
9
- - TEXT / MTEXT / DIMENSION notes: `docs/TEXT-MTEXT-DIMENSION-SUPPORT.md`
10
- - DIMENSION summary (implementation-specific): `docs/DIMENSION_SUMMARY.md`
11
-
12
- ## Testing & Fixtures
13
-
14
- - End-to-end SVG tests (Playwright): `docs/SVG_RENDERING_INTEGRATION_TESTS.md`
15
- - Fixture validation via ezdxf: `docs/FIXTURE_VALIDATION_EZDXF.md`
16
- - Entity-by-entity workflow (fixture → ezdxf → tests): `docs/ENTITY_SVG_ROADMAP.md`
17
-
18
- ## References
19
-
20
- - ezdxf reference sitemap for this repo: `docs/EZDXF_REFERENCE_SITEMAP.md`
21
-
22
- Note: `docs/autocad_2012_pdf_dxf-reference_enu.md` is a local reference copy and is not part of the maintained documentation flow.
@@ -1,119 +0,0 @@
1
- # SVG Rendering Integration Tests
2
-
3
- ## Goal
4
-
5
- Add end-to-end tests that validate the **final SVG output** for real DXF fixtures:
6
-
7
- `DXF fixture → parseString() → (optional denormalise) → toSVG() → SVG assertions`
8
-
9
- The project already has strong unit tests for geometry and parsing. This document defines a predictable integration-test layer to catch regressions at the “final render” boundary.
10
-
11
- ## Framework Choice
12
-
13
- Run the final rendering integration tests in a **real browser** using **Playwright**.
14
-
15
- Rationale:
16
-
17
- - Executes the same rendering code path in a browser runtime.
18
- - Enables future pixel/screenshot tests (if ever needed) without changing frameworks.
19
- - Still supports stable structural assertions (regex/DOM parsing) for deterministic checks.
20
-
21
- ## Where Tests Live
22
-
23
- - Integration tests: `test/integration/**`
24
- - Browser integration tests: `test/integration-browser/**`
25
- - DXF fixtures: `test/resources/*.dxf`
26
-
27
- Browser harness:
28
-
29
- - `test/browser/harness.html`
30
- - Served by `tools/browser_test_server.cjs`
31
-
32
- Scripts:
33
-
34
- - `yarn test:integration` (browser, via Playwright)
35
- - `yarn test:integration:node` (legacy Node-only integration tests)
36
-
37
- ## What Integration Tests Should Assert
38
-
39
- Integration tests should focus on **stable, user-visible output** and avoid overfitting internal implementation details.
40
-
41
- Recommended assertions (in order):
42
-
43
- 1. **SVG well-formed envelope**
44
- - Contains `<svg` and `</svg>`
45
- - Includes `viewBox="..."`
46
-
47
- 2. **Entity-specific rendering markers**
48
- - Presence of SVG elements expected for the entity type (`<line>`, `<path>`, `<circle>`, `<text>`, `<image>`)
49
-
50
- 3. **Critical attributes**
51
- - For example: `marker-start/marker-end` for DIMENSION arrows
52
- - For example: correct path command type for ARC (`A`) or SPLINE (`C/Q`)
53
-
54
- 4. **Text content (when applicable)**
55
- - Assert the final SVG contains the expected text payload
56
-
57
- 5. **No crashes on full fixture set**
58
- - A single integration test can iterate a curated list of fixtures and ensure rendering does not throw.
59
-
60
- ### Saved Render Artifacts (PNG)
61
-
62
- Browser integration tests should save a screenshot under `test/rendered/` for manual review.
63
-
64
- - The file can be overwritten on re-run.
65
- - Prefer a deterministic filename tied to the fixture name, e.g. `test/rendered/dimension-vertical.png`.
66
-
67
- Note: these PNGs are tracked in git. If you regenerate them, include the updated files in your PR.
68
-
69
- ### Handling Non-Deterministic IDs
70
-
71
- Some renderers generate IDs using `Date.now()` (e.g. DIMENSION arrow markers). Integration tests should validate **prefix-based patterns**:
72
-
73
- - `dim-arrow-start-\d+`
74
- - `dim-arrow-end-\d+`
75
-
76
- Avoid asserting the full exact ID.
77
-
78
- ## Golden Files (Optional)
79
-
80
- If/when the project wants pixel-perfect or full-SVG snapshots, consider adding a “golden SVG” snapshot layer.
81
-
82
- Guidelines:
83
-
84
- - Only snapshot **small, stable fixtures**.
85
- - Normalize dynamic values (e.g. marker IDs) before snapshotting.
86
- - Keep snapshots per-fixture under `test/snapshots/`.
87
-
88
- This is intentionally optional; regex-based structural assertions are the default.
89
-
90
- ## DIMENSION: First Integration Target
91
-
92
- Start with fixtures that include real DIMENSION output:
93
-
94
- - `test/resources/dimension-vertical.dxf`
95
-
96
- Suggested assertions:
97
-
98
- - Markers exist (`<marker id="dim-arrow-start-..."`)
99
- - Dimension line uses `marker-start/marker-end`
100
- - Text appears in SVG (fixture includes `5.35`)
101
-
102
- See:
103
-
104
- - `test/integration-browser/dimension-rendering.browser.spec.js`
105
-
106
- ## Adding a New Integration Test (Checklist)
107
-
108
- 1. Pick or create a DXF fixture under `test/resources/`.
109
- 2. (Recommended) Validate it with `yarn validate:fixtures` (see `docs/FIXTURE_VALIDATION_EZDXF.md`).
110
- 3. Add a new `test/integration/*.integration.test.js`.
111
- - Or, for browser execution, add `test/integration-browser/*.browser.spec.js`.
112
- 4. Assert:
113
- - SVG envelope + viewBox
114
- - Entity-specific elements
115
- - Critical attributes
116
- - Screenshot is saved to `test/rendered/<fixture-name>.png` (overwrite on re-run)
117
- 5. Run:
118
- - `yarn test:unit`
119
- - `yarn test:integration`
@@ -1,241 +0,0 @@
1
- # TEXT, MTEXT and DIMENSION - SVG Rendering Support# TEXT, MTEXT e DIMENSION - Suporte de Renderização SVG
2
-
3
- ## Summary of Changes## Resumo das Mudanças
4
-
5
- Added complete support for rendering TEXT, MTEXT, and DIMENSION entities in SVG.Adicionado suporte completo para renderização de entidades TEXT, MTEXT e DIMENSION em SVG.
6
-
7
- ## Supported Entities## Entidades Suportadas
8
-
9
- ### TEXT### TEXT
10
-
11
- - Basic text rendering- Renderização básica de texto
12
-
13
- - Rotation support (code 50)- Suporte para rotação (código 50)
14
-
15
- - Positioning support (codes 10, 20, 30)- Suporte para posicionamento (códigos 10, 20, 30)
16
-
17
- - Text height support (code 40)- Suporte para altura do texto (código 40)
18
-
19
- - Horizontal and vertical alignment (codes 72, 73)- Alinhamento horizontal e vertical (códigos 72, 73)
20
-
21
- ### MTEXT### MTEXT
22
-
23
- - Multi-line text rendering- Renderização de texto multilinha
24
-
25
- - Rotation support via X-axis direction (codes 11, 21)- Suporte para rotação via direção do eixo X (códigos 11, 21)
26
-
27
- - Reference rectangle width support (code 41)- Suporte para largura do retângulo de referência (código 41)
28
-
29
- - Nominal text height (code 40)- Altura nominal do texto (código 40)
30
-
31
- - Attachment point (code 71)- Ponto de fixação (código 71)
32
-
33
- ### DIMENSION### DIMENSION
34
-
35
- Support for all dimension types:Suporte para todos os tipos de dimensão:
36
-
37
- #### Type 0 - Rotated, horizontal or vertical#### Tipo 0 - Rotated, horizontal ou vertical
38
-
39
- - Extension lines- Linhas de extensão
40
-
41
- - Dimension line- Linha de dimensão
42
-
43
- - Dimension text- Texto de dimensão
44
-
45
- #### Type 1 - Aligned#### Tipo 1 - Aligned (alinhada)
46
-
47
- - Dimension line aligned with measured points- Linha de dimensão alinhada com os pontos medidos
48
-
49
- - Perpendicular extension lines- Linhas de extensão perpendiculares
50
-
51
- #### Type 2 - Angular#### Tipo 2 - Angular (angular)
52
-
53
- - Angle dimension between two lines- Dimensão de ângulo entre duas linhas
54
-
55
- #### Type 3 - Diameter#### Tipo 3 - Diameter (diâmetro)
56
-
57
- - Radial dimension line for diameters- Linha de dimensão radial para diâmetros
58
-
59
- - Text with diameter symbol- Texto com símbolo de diâmetro
60
-
61
- #### Type 4 - Radius#### Tipo 4 - Radius (raio)
62
-
63
- - Radial dimension line- Linha de dimensão radial
64
-
65
- - Text with R prefix- Texto com prefixo R
66
-
67
- #### Type 5 - Angular 3 point#### Tipo 5 - Angular 3 point (angular 3 pontos)
68
-
69
- - Angular dimension defined by 3 points- Dimensão angular definida por 3 pontos
70
-
71
- #### Type 6 - Ordinate#### Tipo 6 - Ordinate (ordenada)
72
-
73
- - X or Y coordinate dimension- Dimensão de coordenada X ou Y
74
-
75
- - Simple extension line- Linha de extensão simples
76
-
77
- ## Implemented DXF Codes## Códigos DXF Implementados
78
-
79
- ### TEXT
80
-
81
- | Code | Description || Código | Descrição |
82
-
83
- |------|-------------||--------|-----------|
84
-
85
- | 1 | Text content || 1 | Conteúdo do texto |
86
-
87
- | 10, 20, 30 | Insertion point (x, y, z) || 10, 20, 30 | Ponto de inserção (x, y, z) |
88
-
89
- | 11, 21, 31 | Second alignment point || 11, 21, 31 | Segundo ponto de alinhamento |
90
-
91
- | 40 | Text height || 40 | Altura do texto |
92
-
93
- | 41 | Relative X scale || 41 | Escala relativa X |
94
-
95
- | 50 | Rotation in degrees || 50 | Rotação em graus |
96
-
97
- | 51 | Oblique angle || 51 | Ângulo oblíquo |
98
-
99
- | 72 | Horizontal alignment || 72 | Alinhamento horizontal |
100
-
101
- | 73 | Vertical alignment || 73 | Alinhamento vertical |
102
-
103
- ### MTEXT### MTEXT
104
-
105
- | Code | Description || Código | Descrição |
106
-
107
- |------|-------------||--------|-----------|
108
-
109
- | 1, 3 | Text content || 1, 3 | Conteúdo do texto |
110
-
111
- | 10, 20, 30 | Insertion point || 10, 20, 30 | Ponto de inserção |
112
-
113
- | 11, 21, 31 | X-axis direction || 11, 21, 31 | Direção do eixo X |
114
-
115
- | 40 | Nominal text height || 40 | Altura nominal do texto |
116
-
117
- | 41 | Reference rectangle width || 41 | Largura do retângulo de referência |
118
-
119
- | 71 | Attachment point || 71 | Ponto de fixação |
120
-
121
- | 72 | Drawing direction || 72 | Direção do desenho |
122
-
123
- ### DIMENSION### DIMENSION
124
-
125
- | Code | Description || Código | Descrição |
126
-
127
- |------|-------------||--------|-----------|
128
-
129
- | 2 | Block name || 2 | Nome do bloco |
130
-
131
- | 10, 20, 30 | Definition point || 10, 20, 30 | Ponto de definição |
132
-
133
- | 11, 21, 31 | Text midpoint || 11, 21, 31 | Ponto médio do texto |
134
-
135
- | 13, 23, 33 | Measurement start point || 13, 23, 33 | Ponto inicial da medida |
136
-
137
- | 14, 24, 34 | Measurement end point || 14, 24, 34 | Ponto final da medida |
138
-
139
- | 50 | Rotation angle || 50 | Ângulo de rotação |
140
-
141
- | 70 | Dimension type || 70 | Tipo de dimensão |
142
-
143
- ## Usage Example## Exemplo de Uso
144
-
145
- ```javascript```javascript
146
-
147
- import { Helper } from '@linkiez/dxf-renew'
148
-
149
- const dxfString = `... DXF content ...`const dxfString = `... conteúdo DXF ...`
150
-
151
- const helper = new Helper(dxfString)const helper = new Helper(dxfString)
152
-
153
- // Convert to SVG (now includes TEXT, MTEXT and DIMENSION)// Converter para SVG (agora inclui TEXT, MTEXT e DIMENSION)
154
-
155
- const svg = helper.toSVG()const svg = helper.toSVG()
156
-
157
- ```
158
-
159
-
160
-
161
- ## Tests## Testes
162
-
163
-
164
-
165
- Unit tests have been added in `test/unit/text-mtext-dimension-rendering.js` that verify:Foram adicionados testes unitários em `test/unit/text-mtext-dimension-rendering.js` que verificam:
166
-
167
-
168
-
169
- - Basic TEXT rendering- Renderização básica de TEXT
170
-
171
- - Basic MTEXT rendering- Renderização básica de MTEXT
172
-
173
- - DIMENSION rendering- Renderização de DIMENSION
174
-
175
- - TEXT rotation- Rotação de TEXT
176
-
177
- - MTEXT rotation via X-axis direction- Rotação de MTEXT via direção do eixo X
178
-
179
- - Different DIMENSION types- Diferentes tipos de DIMENSION
180
-
181
-
182
-
183
- Run tests with:Execute os testes com:
184
-
185
-
186
-
187
- ```bash```bash
188
-
189
- npm testnpm test
190
-
191
- ``````
192
-
193
- ## Visual Example## Exemplo Visual
194
-
195
- An interactive visual example is available at `examples/text-dimension-viewer.html`.Um exemplo visual interativo está disponível em `examples/text-dimension-viewer.html`.
196
-
197
- To view:Para visualizar:
198
-
199
- 1. Run `npm run build` to generate the bundle1. Execute `npm run build` para gerar o bundle
200
-
201
- 2. Open `examples/text-dimension-viewer.html` in a browser2. Abra `examples/text-dimension-viewer.html` em um navegador
202
-
203
- 3. Load a DXF file or use the provided test files3. Carregue um arquivo DXF ou use os arquivos de teste fornecidos
204
-
205
- ## Known Limitations## Limitações Conhecidas
206
-
207
- 1. **TEXT and MTEXT**:1. **TEXT e MTEXT**:
208
-
209
- - Font is not respected (uses browser default font) - Fonte não é respeitada (usa fonte padrão do navegador)
210
-
211
- - Complex MTEXT formatting is not fully supported - Formatação complexa de MTEXT não é totalmente suportada
212
-
213
- - Bounding box calculation is approximate - Cálculo de bounding box é aproximado
214
-
215
- 2. **DIMENSION**:2. **DIMENSION**:
216
-
217
- - Custom dimension blocks are not rendered - Blocos de dimensão personalizados não são renderizados
218
-
219
- - Only basic dimension lines are drawn - Apenas linhas básicas de dimensão são desenhadas
220
-
221
- - Dimension text is not displayed (needs to be extracted from block) - Texto de dimensão não é exibido (precisa ser extraído do bloco)
222
-
223
- - Arrows are not rendered - Setas não são renderizadas
224
-
225
- ## Modified Files## Arquivos Modificados
226
-
227
- - `src/toSVG.js`: Added `text()`, `mtext()`, `dimension()` and `createDimensionPaths()` functions- `src/toSVG.js`: Adicionadas funções `text()`, `mtext()`, `dimension()` e `createDimensionPaths()`
228
-
229
- - `test/unit/text-mtext-dimension-rendering.js`: New unit tests- `test/unit/text-mtext-dimension-rendering.js`: Novos testes unitários
230
-
231
- - `examples/text-dimension-viewer.html`: Interactive visual example
232
-
233
- ## Next Steps
234
-
235
- To further improve support:
236
-
237
- 1. Implement dimension arrow rendering
238
- 2. Extract and render dimension text from blocks
239
- 3. Support custom text styles
240
- 4. Improve bounding box calculation for text
241
- 5. Support advanced MTEXT formatting (colors, bold, etc.)