build123d-drafting-helpers 0.1.0__tar.gz

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.
@@ -0,0 +1,8 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ .venv/
5
+ *.egg-info/
6
+ dist/
7
+ build/
8
+ .pytest_cache/
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ ## v0.1.0 — 2026-05-19
4
+
5
+ First PyPI release.
6
+
7
+ Renamed from `build123d-drafting` to `build123d-drafting-helpers` to signal the third-party status of the package (it is not affiliated with the upstream build123d project). The Python import name is unchanged — existing `from build123d_drafting import ...` lines continue to work.
8
+
9
+ ### Helpers
10
+
11
+ - `dim_linear(p1, p2, side, distance, draft, label=None, tolerance=None)` — named-side wrapper over `build123d.ExtensionLine`. Returns `DimResult(shape, label_str, measured_length)`.
12
+ - `safe_dim_line(path, label, draft, fallback_label=None)` — `DimensionLine` wrapper that won't raise when the label is wider than the dim path.
13
+ - `leader(tip, elbow, label, draft)` — leader annotation built from scratch; line stops cleanly before the label. Returns `LeaderResult(lines, text, label_str, tip, elbow)`.
14
+ - `view_axes(viewport_origin, viewport_up, look_at)` — analytic world-to-page axis mapping for `project_to_viewport`.
15
+ - `lint_drawing(items, part_bbox=None)` — structural checks (label-vs-length divergence, dim inside view, leader through label).
16
+ - `iso_title_block(...)` — standalone title box (not a substitute for `build123d.TechnicalDrawing`, which is a whole-page chrome; this is the title box alone, positionable anywhere, with separate `lines`/`text` `Compound`s for SVG layer routing and additional `material` / `general_tolerance` fields).
17
+ - `surface_finish_mark(ra_value, position, ...)` — ISO 1302 Ra-value check-mark symbol; build123d does not ship one.
@@ -0,0 +1,184 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other transformations
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of developing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and included
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent contributions made by
76
+ such Contributor that are necessarily infringed by their Contribution(s)
77
+ alone or by the combination of their Contribution(s) with the Work to
78
+ which such Contribution(s) was submitted. If You institute patent
79
+ litigation against any entity (including a cross-claim or counterclaim
80
+ in a lawsuit) alleging that the Work or any portion of the Work
81
+ constitutes direct or contributory patent infringement, then any patent
82
+ licenses granted to You under this License for that Work shall terminate
83
+ as of the date such litigation is filed.
84
+
85
+ 4. Redistribution. You may reproduce and distribute copies of the
86
+ Work or Derivative Works thereof in any medium, with or without
87
+ modifications, and in Source or Object form, provided that You
88
+ meet the following conditions:
89
+
90
+ (a) You must give any other recipients of the Work or Derivative
91
+ Works a copy of this License; and
92
+
93
+ (b) You must cause any modified files to carry prominent notices
94
+ stating that You changed the files; and
95
+
96
+ (c) You must retain, in the Source form of any Derivative Works
97
+ that You distribute, all copyright, patent, trademark, and
98
+ attribution notices from the Source form of the Work,
99
+ excluding those notices that do not pertain to any part of
100
+ the Derivative Works; and
101
+
102
+ (d) If the Work includes a "NOTICE" text file as part of its
103
+ distribution, You must include a readable copy of the
104
+ attribution notices contained within such NOTICE file, in
105
+ at least one of the following places: within a NOTICE text
106
+ file distributed as part of the Derivative Works; within
107
+ the Source form or documentation, if provided along with the
108
+ Derivative Works; or, within a display generated by the
109
+ Derivative Works, if and wherever such third-party notices
110
+ normally appear. The contents of the NOTICE file are for
111
+ informational purposes only and do not modify the License.
112
+ You may add Your own attribution notices within Derivative
113
+ Works that You distribute, alongside or in addition to the
114
+ NOTICE text from the Work, provided that such additional
115
+ attribution notices cannot be construed as modifying the License.
116
+
117
+ You may add Your own license statement for Your modifications and
118
+ may provide additional grant of rights to use, copy, modify, merge,
119
+ publish, distribute, sublicense, and/or sell copies of the
120
+ Contribution, either on an "as is" basis or under different terms and
121
+ conditions, provided that Your use of the Contribution does not
122
+ otherwise conflict with the terms and conditions of this License.
123
+
124
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
125
+ any Contribution intentionally submitted for inclusion in the Work
126
+ by You to the Licensor shall be under the terms and conditions of
127
+ this License, without any additional terms or conditions.
128
+ Notwithstanding the above, nothing herein shall supersede or modify
129
+ the terms of any separate license agreement you may have executed
130
+ with Licensor regarding such Contributions.
131
+
132
+ 6. Trademarks. This License does not grant permission to use the trade
133
+ names, trademarks, service marks, or product names of the Licensor,
134
+ except as required for reasonable and customary use in describing the
135
+ origin of the Work and reproducing the content of the NOTICE file.
136
+
137
+ 7. Disclaimer of Warranty. Unless required by applicable law or
138
+ agreed to in writing, Licensor provides the Work (and each
139
+ Contributor provides its Contributions) on an "AS IS" BASIS,
140
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
141
+ implied, including, without limitation, any warranties or conditions
142
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
143
+ PARTICULAR PURPOSE. You are solely responsible for determining the
144
+ appropriateness of using or reproducing the Work and assume any
145
+ risks associated with Your exercise of permissions under this License.
146
+
147
+ 8. Limitation of Liability. In no event and under no legal theory,
148
+ whether in tort (including negligence), contract, or otherwise,
149
+ unless required by applicable law (such as deliberate and grossly
150
+ negligent acts) or agreed to in writing, shall any Contributor be
151
+ liable to You for damages, including any direct, indirect, special,
152
+ incidental, or exemplary damages of any character arising as a
153
+ result of this License or out of the use or inability to use the
154
+ Work (including but not limited to damages for loss of goodwill,
155
+ work stoppage, computer failure or malfunction, or all other
156
+ commercial damages or losses), even if such Contributor has been
157
+ advised of the possibility of such damages.
158
+
159
+ 9. Accepting Warranty or Liability. While redistributing the Work or
160
+ Derivative Works thereof, You may choose to offer, and charge a fee
161
+ for, acceptance of support, warranty, indemnity, or other liability
162
+ obligations and/or rights consistent with this License. However, in
163
+ accepting such obligations, You may offer such obligations only on
164
+ Your own behalf and on Your sole responsibility, not on behalf of
165
+ any other Contributor, and only if You agree to indemnify, defend,
166
+ and hold each Contributor harmless for any liability incurred by, or
167
+ claims asserted against, such Contributor by reason of your accepting
168
+ any such warranty or additional liability.
169
+
170
+ END OF TERMS AND CONDITIONS
171
+
172
+ Copyright 2024 Paul Fremantle
173
+
174
+ Licensed under the Apache License, Version 2.0 (the "License");
175
+ you may not use this file except in compliance with the License.
176
+ You may obtain a copy of the License at
177
+
178
+ http://www.apache.org/licenses/LICENSE-2.0
179
+
180
+ Unless required by applicable law or agreed to in writing, software
181
+ distributed under the License is distributed on an "AS IS" BASIS,
182
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183
+ See the License for the specific language governing permissions and
184
+ limitations under the License.
@@ -0,0 +1,328 @@
1
+ Metadata-Version: 2.4
2
+ Name: build123d-drafting-helpers
3
+ Version: 0.1.0
4
+ Summary: Third-party drawing-annotation helpers for build123d — dim_linear, leader, view_axes, lint_drawing
5
+ Project-URL: Homepage, https://github.com/pzfreo/build123d-drafting-helpers
6
+ Project-URL: Repository, https://github.com/pzfreo/build123d-drafting-helpers
7
+ Project-URL: Issues, https://github.com/pzfreo/build123d-drafting-helpers/issues
8
+ Project-URL: Changelog, https://github.com/pzfreo/build123d-drafting-helpers/blob/main/CHANGELOG.md
9
+ Author-email: Paul Fremantle <pzfreo@gmail.com>
10
+ License: Apache License
11
+ Version 2.0, January 2004
12
+ http://www.apache.org/licenses/
13
+
14
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
15
+
16
+ 1. Definitions.
17
+
18
+ "License" shall mean the terms and conditions for use, reproduction,
19
+ and distribution as defined by Sections 1 through 9 of this document.
20
+
21
+ "Licensor" shall mean the copyright owner or entity authorized by
22
+ the copyright owner that is granting the License.
23
+
24
+ "Legal Entity" shall mean the union of the acting entity and all
25
+ other entities that control, are controlled by, or are under common
26
+ control with that entity. For the purposes of this definition,
27
+ "control" means (i) the power, direct or indirect, to cause the
28
+ direction or management of such entity, whether by contract or
29
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
30
+ outstanding shares, or (iii) beneficial ownership of such entity.
31
+
32
+ "You" (or "Your") shall mean an individual or Legal Entity
33
+ exercising permissions granted by this License.
34
+
35
+ "Source" form shall mean the preferred form for making modifications,
36
+ including but not limited to software source code, documentation
37
+ source, and configuration files.
38
+
39
+ "Object" form shall mean any form resulting from mechanical
40
+ transformation or translation of a Source form, including but
41
+ not limited to compiled object code, generated documentation,
42
+ and conversions to other media types.
43
+
44
+ "Work" shall mean the work of authorship made available under
45
+ the License, as indicated by a copyright notice that is included in
46
+ or attached to the work (an example is provided in the Appendix below).
47
+
48
+ "Derivative Works" shall mean any work, whether in Source or Object
49
+ form, that is based on (or derived from) the Work and for which the
50
+ editorial revisions, annotations, elaborations, or other transformations
51
+ represent, as a whole, an original work of authorship. For the purposes
52
+ of this License, Derivative Works shall not include works that remain
53
+ separable from, or merely link (or bind by name) to the interfaces of,
54
+ the Work and Derivative Works thereof.
55
+
56
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
57
+ in the Work by the copyright owner or by an individual or Legal Entity
58
+ authorized to submit on behalf of the copyright owner. For the purposes
59
+ of this definition, "submitted" means any form of electronic, verbal,
60
+ or written communication sent to the Licensor or its representatives,
61
+ including but not limited to communication on electronic mailing lists,
62
+ source code control systems, and issue tracking systems that are managed
63
+ by, or on behalf of, the Licensor for the purpose of developing and
64
+ improving the Work, but excluding communication that is conspicuously
65
+ marked or designated in writing by the copyright owner as "Not a
66
+ Contribution."
67
+
68
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
69
+ whom a Contribution has been received by the Licensor and included
70
+ within the Work.
71
+
72
+ 2. Grant of Copyright License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ copyright license to reproduce, prepare Derivative Works of,
76
+ publicly display, publicly perform, sublicense, and distribute the
77
+ Work and such Derivative Works in Source or Object form.
78
+
79
+ 3. Grant of Patent License. Subject to the terms and conditions of
80
+ this License, each Contributor hereby grants to You a perpetual,
81
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
82
+ (except as stated in this section) patent license to make, have made,
83
+ use, offer to sell, sell, import, and otherwise transfer the Work,
84
+ where such license applies only to those patent contributions made by
85
+ such Contributor that are necessarily infringed by their Contribution(s)
86
+ alone or by the combination of their Contribution(s) with the Work to
87
+ which such Contribution(s) was submitted. If You institute patent
88
+ litigation against any entity (including a cross-claim or counterclaim
89
+ in a lawsuit) alleging that the Work or any portion of the Work
90
+ constitutes direct or contributory patent infringement, then any patent
91
+ licenses granted to You under this License for that Work shall terminate
92
+ as of the date such litigation is filed.
93
+
94
+ 4. Redistribution. You may reproduce and distribute copies of the
95
+ Work or Derivative Works thereof in any medium, with or without
96
+ modifications, and in Source or Object form, provided that You
97
+ meet the following conditions:
98
+
99
+ (a) You must give any other recipients of the Work or Derivative
100
+ Works a copy of this License; and
101
+
102
+ (b) You must cause any modified files to carry prominent notices
103
+ stating that You changed the files; and
104
+
105
+ (c) You must retain, in the Source form of any Derivative Works
106
+ that You distribute, all copyright, patent, trademark, and
107
+ attribution notices from the Source form of the Work,
108
+ excluding those notices that do not pertain to any part of
109
+ the Derivative Works; and
110
+
111
+ (d) If the Work includes a "NOTICE" text file as part of its
112
+ distribution, You must include a readable copy of the
113
+ attribution notices contained within such NOTICE file, in
114
+ at least one of the following places: within a NOTICE text
115
+ file distributed as part of the Derivative Works; within
116
+ the Source form or documentation, if provided along with the
117
+ Derivative Works; or, within a display generated by the
118
+ Derivative Works, if and wherever such third-party notices
119
+ normally appear. The contents of the NOTICE file are for
120
+ informational purposes only and do not modify the License.
121
+ You may add Your own attribution notices within Derivative
122
+ Works that You distribute, alongside or in addition to the
123
+ NOTICE text from the Work, provided that such additional
124
+ attribution notices cannot be construed as modifying the License.
125
+
126
+ You may add Your own license statement for Your modifications and
127
+ may provide additional grant of rights to use, copy, modify, merge,
128
+ publish, distribute, sublicense, and/or sell copies of the
129
+ Contribution, either on an "as is" basis or under different terms and
130
+ conditions, provided that Your use of the Contribution does not
131
+ otherwise conflict with the terms and conditions of this License.
132
+
133
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
134
+ any Contribution intentionally submitted for inclusion in the Work
135
+ by You to the Licensor shall be under the terms and conditions of
136
+ this License, without any additional terms or conditions.
137
+ Notwithstanding the above, nothing herein shall supersede or modify
138
+ the terms of any separate license agreement you may have executed
139
+ with Licensor regarding such Contributions.
140
+
141
+ 6. Trademarks. This License does not grant permission to use the trade
142
+ names, trademarks, service marks, or product names of the Licensor,
143
+ except as required for reasonable and customary use in describing the
144
+ origin of the Work and reproducing the content of the NOTICE file.
145
+
146
+ 7. Disclaimer of Warranty. Unless required by applicable law or
147
+ agreed to in writing, Licensor provides the Work (and each
148
+ Contributor provides its Contributions) on an "AS IS" BASIS,
149
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
150
+ implied, including, without limitation, any warranties or conditions
151
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
152
+ PARTICULAR PURPOSE. You are solely responsible for determining the
153
+ appropriateness of using or reproducing the Work and assume any
154
+ risks associated with Your exercise of permissions under this License.
155
+
156
+ 8. Limitation of Liability. In no event and under no legal theory,
157
+ whether in tort (including negligence), contract, or otherwise,
158
+ unless required by applicable law (such as deliberate and grossly
159
+ negligent acts) or agreed to in writing, shall any Contributor be
160
+ liable to You for damages, including any direct, indirect, special,
161
+ incidental, or exemplary damages of any character arising as a
162
+ result of this License or out of the use or inability to use the
163
+ Work (including but not limited to damages for loss of goodwill,
164
+ work stoppage, computer failure or malfunction, or all other
165
+ commercial damages or losses), even if such Contributor has been
166
+ advised of the possibility of such damages.
167
+
168
+ 9. Accepting Warranty or Liability. While redistributing the Work or
169
+ Derivative Works thereof, You may choose to offer, and charge a fee
170
+ for, acceptance of support, warranty, indemnity, or other liability
171
+ obligations and/or rights consistent with this License. However, in
172
+ accepting such obligations, You may offer such obligations only on
173
+ Your own behalf and on Your sole responsibility, not on behalf of
174
+ any other Contributor, and only if You agree to indemnify, defend,
175
+ and hold each Contributor harmless for any liability incurred by, or
176
+ claims asserted against, such Contributor by reason of your accepting
177
+ any such warranty or additional liability.
178
+
179
+ END OF TERMS AND CONDITIONS
180
+
181
+ Copyright 2024 Paul Fremantle
182
+
183
+ Licensed under the Apache License, Version 2.0 (the "License");
184
+ you may not use this file except in compliance with the License.
185
+ You may obtain a copy of the License at
186
+
187
+ http://www.apache.org/licenses/LICENSE-2.0
188
+
189
+ Unless required by applicable law or agreed to in writing, software
190
+ distributed under the License is distributed on an "AS IS" BASIS,
191
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
192
+ See the License for the specific language governing permissions and
193
+ limitations under the License.
194
+ License-File: LICENSE
195
+ Keywords: build123d,cad,dimensions,drafting,engineering-drawing
196
+ Classifier: Development Status :: 3 - Alpha
197
+ Classifier: Intended Audience :: Developers
198
+ Classifier: Intended Audience :: Manufacturing
199
+ Classifier: License :: OSI Approved :: Apache Software License
200
+ Classifier: Programming Language :: Python :: 3
201
+ Classifier: Programming Language :: Python :: 3.10
202
+ Classifier: Programming Language :: Python :: 3.11
203
+ Classifier: Programming Language :: Python :: 3.12
204
+ Classifier: Topic :: Scientific/Engineering
205
+ Requires-Python: >=3.10
206
+ Requires-Dist: build123d>=0.7.0
207
+ Description-Content-Type: text/markdown
208
+
209
+ # build123d-drafting-helpers
210
+
211
+ [![PyPI](https://img.shields.io/pypi/v/build123d-drafting-helpers.svg)](https://pypi.org/project/build123d-drafting-helpers/)
212
+ [![Python](https://img.shields.io/pypi/pyversions/build123d-drafting-helpers.svg)](https://pypi.org/project/build123d-drafting-helpers/)
213
+ [![License](https://img.shields.io/pypi/l/build123d-drafting-helpers.svg)](LICENSE)
214
+
215
+ Third-party drawing-annotation helpers for [build123d](https://github.com/gumyr/build123d) — pure Python, no MCP dependency. Not affiliated with the upstream build123d project.
216
+
217
+ ```python
218
+ from build123d_drafting import dim_linear, leader, view_axes, lint_drawing
219
+ ```
220
+
221
+ The install name is `build123d-drafting-helpers`; the import name is `build123d_drafting`.
222
+
223
+ > **Not to be confused with [`baverman/build123d_draft`](https://github.com/baverman/build123d_draft)** — that project is *modelling shortcuts* (slot helpers, rotation aliases, `build_line` wrappers), not drafting/annotation. Different scope despite the similar name.
224
+
225
+ ## Installation
226
+
227
+ ```
228
+ pip install build123d-drafting-helpers
229
+ ```
230
+
231
+ Or with uv:
232
+
233
+ ```
234
+ uv add build123d-drafting-helpers
235
+ ```
236
+
237
+ Requires `build123d >= 0.7.0` and Python ≥ 3.10.
238
+
239
+ ## Helpers
240
+
241
+ ### `dim_linear(p1, p2, side, distance, draft, label=None, tolerance=None)`
242
+
243
+ `ExtensionLine` wrapper with named placement side instead of raw signed offset.
244
+
245
+ ```python
246
+ draft = Draft(font_size=2.5, decimal_precision=1)
247
+ dim = dim_linear((-20, -10, 0), (20, -10, 0), "below", 8, draft, label="40")
248
+ ```
249
+
250
+ `side` accepts `"above"` / `"below"` / `"left"` / `"right"` or an explicit world-direction vector.
251
+ The correct `offset` sign is computed from the path direction's right-hand normal — no guessing.
252
+
253
+ Returns a `DimResult(shape, label_str, measured_length)`.
254
+
255
+ ---
256
+
257
+ ### `safe_dim_line(path, label, draft, fallback_label=None)`
258
+
259
+ `DimensionLine` wrapper that won't raise `ValueError` when the label is wider than the dim path.
260
+ Truncates gracefully and retries.
261
+
262
+ ---
263
+
264
+ ### `leader(tip, elbow, label, draft)`
265
+
266
+ Leader annotation built from scratch. The line stops cleanly before the label text.
267
+
268
+ ```python
269
+ res = leader((5, 5, 0), (20, 12, 0), "⌀7.93 H7", draft)
270
+ exporter.add_shape(res.lines, layer="dims") # arrowhead + shelf — fill_color layer
271
+ exporter.add_shape(res.text, layer="text") # glyphs — fill_color layer
272
+ ```
273
+
274
+ Returns `LeaderResult(lines, text, label_str, tip, elbow)`. Route `lines` and `text` to
275
+ separate SVG layers, both with `fill_color` set.
276
+
277
+ ---
278
+
279
+ ### `view_axes(viewport_origin, viewport_up=(0,1,0), look_at=(0,0,0))`
280
+
281
+ Returns the world→page axis mapping for a `project_to_viewport` call, computed analytically.
282
+
283
+ ```python
284
+ axes = view_axes((0, 0, -100), (0, 1, 0), (0, 0, 0))
285
+ # {"world_X": ("page_X", -1.0), "world_Y": ("page_Y", 1.0), "world_Z": ("depth", 0.0)}
286
+ # ↑ bottom view flips world-X on the page
287
+ ```
288
+
289
+ ---
290
+
291
+ ### `lint_drawing(items, part_bbox=None)`
292
+
293
+ Structural checks on a list of `DimResult` / `LeaderResult` objects:
294
+
295
+ - Label numeric value differs from measured path length by >0.5% (likely axis swap)
296
+ - Dim bbox overlaps part outline by >10% (dim placed inside the view)
297
+ - Leader elbow point inside label bbox (line strikes through text)
298
+
299
+ ```python
300
+ issues = lint_drawing([dim1, dim2, lea1])
301
+ for issue in issues:
302
+ print(issue.severity, issue.message)
303
+ ```
304
+
305
+ ---
306
+
307
+ ### `iso_title_block(...)` and `surface_finish_mark(...)`
308
+
309
+ `iso_title_block` is a **standalone title box** (170 × 16 mm by default), positioned by the caller. It is *not* a substitute for `build123d.TechnicalDrawing`, which is a whole-page chrome — page-sized border + grid ticks + embedded title box, returned as a single `Sketch`. Use `TechnicalDrawing` when you want the full drawing-sheet frame; reach for `iso_title_block` when you want just the title box, positionable anywhere, with separate `lines`/`text` `Compound`s for SVG layer routing, and with `material` / `general_tolerance` fields that `TechnicalDrawing` does not carry.
310
+
311
+ `surface_finish_mark` produces an ISO 1302 Ra-value check-mark symbol — build123d does not ship one.
312
+
313
+ ## Status against upstream
314
+
315
+ - `lint_drawing` is a prototype of rule-based drawing checks that build123d's roadmap mentions as future work. If upstream ships its own linter later, this one can be deprecated.
316
+ - `dim_linear` is a thin convenience wrapper over `ExtensionLine` — it does not replace the underlying class, it just lets you write `side="above"` instead of computing the right-hand-normal signed offset by hand. If upstream adds a named-side parameter, this helper becomes redundant.
317
+
318
+ ## Development
319
+
320
+ ```
321
+ git clone https://github.com/pzfreo/build123d-drafting-helpers.git
322
+ cd build123d-drafting-helpers
323
+ uv run pytest tests/
324
+ ```
325
+
326
+ ## Status
327
+
328
+ Alpha. API may change. Developed alongside [build123d-mcp](https://github.com/pzfreo/build123d-mcp), which integrates these helpers into its LLM-facing drawing workflow.
@@ -0,0 +1,120 @@
1
+ # build123d-drafting-helpers
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/build123d-drafting-helpers.svg)](https://pypi.org/project/build123d-drafting-helpers/)
4
+ [![Python](https://img.shields.io/pypi/pyversions/build123d-drafting-helpers.svg)](https://pypi.org/project/build123d-drafting-helpers/)
5
+ [![License](https://img.shields.io/pypi/l/build123d-drafting-helpers.svg)](LICENSE)
6
+
7
+ Third-party drawing-annotation helpers for [build123d](https://github.com/gumyr/build123d) — pure Python, no MCP dependency. Not affiliated with the upstream build123d project.
8
+
9
+ ```python
10
+ from build123d_drafting import dim_linear, leader, view_axes, lint_drawing
11
+ ```
12
+
13
+ The install name is `build123d-drafting-helpers`; the import name is `build123d_drafting`.
14
+
15
+ > **Not to be confused with [`baverman/build123d_draft`](https://github.com/baverman/build123d_draft)** — that project is *modelling shortcuts* (slot helpers, rotation aliases, `build_line` wrappers), not drafting/annotation. Different scope despite the similar name.
16
+
17
+ ## Installation
18
+
19
+ ```
20
+ pip install build123d-drafting-helpers
21
+ ```
22
+
23
+ Or with uv:
24
+
25
+ ```
26
+ uv add build123d-drafting-helpers
27
+ ```
28
+
29
+ Requires `build123d >= 0.7.0` and Python ≥ 3.10.
30
+
31
+ ## Helpers
32
+
33
+ ### `dim_linear(p1, p2, side, distance, draft, label=None, tolerance=None)`
34
+
35
+ `ExtensionLine` wrapper with named placement side instead of raw signed offset.
36
+
37
+ ```python
38
+ draft = Draft(font_size=2.5, decimal_precision=1)
39
+ dim = dim_linear((-20, -10, 0), (20, -10, 0), "below", 8, draft, label="40")
40
+ ```
41
+
42
+ `side` accepts `"above"` / `"below"` / `"left"` / `"right"` or an explicit world-direction vector.
43
+ The correct `offset` sign is computed from the path direction's right-hand normal — no guessing.
44
+
45
+ Returns a `DimResult(shape, label_str, measured_length)`.
46
+
47
+ ---
48
+
49
+ ### `safe_dim_line(path, label, draft, fallback_label=None)`
50
+
51
+ `DimensionLine` wrapper that won't raise `ValueError` when the label is wider than the dim path.
52
+ Truncates gracefully and retries.
53
+
54
+ ---
55
+
56
+ ### `leader(tip, elbow, label, draft)`
57
+
58
+ Leader annotation built from scratch. The line stops cleanly before the label text.
59
+
60
+ ```python
61
+ res = leader((5, 5, 0), (20, 12, 0), "⌀7.93 H7", draft)
62
+ exporter.add_shape(res.lines, layer="dims") # arrowhead + shelf — fill_color layer
63
+ exporter.add_shape(res.text, layer="text") # glyphs — fill_color layer
64
+ ```
65
+
66
+ Returns `LeaderResult(lines, text, label_str, tip, elbow)`. Route `lines` and `text` to
67
+ separate SVG layers, both with `fill_color` set.
68
+
69
+ ---
70
+
71
+ ### `view_axes(viewport_origin, viewport_up=(0,1,0), look_at=(0,0,0))`
72
+
73
+ Returns the world→page axis mapping for a `project_to_viewport` call, computed analytically.
74
+
75
+ ```python
76
+ axes = view_axes((0, 0, -100), (0, 1, 0), (0, 0, 0))
77
+ # {"world_X": ("page_X", -1.0), "world_Y": ("page_Y", 1.0), "world_Z": ("depth", 0.0)}
78
+ # ↑ bottom view flips world-X on the page
79
+ ```
80
+
81
+ ---
82
+
83
+ ### `lint_drawing(items, part_bbox=None)`
84
+
85
+ Structural checks on a list of `DimResult` / `LeaderResult` objects:
86
+
87
+ - Label numeric value differs from measured path length by >0.5% (likely axis swap)
88
+ - Dim bbox overlaps part outline by >10% (dim placed inside the view)
89
+ - Leader elbow point inside label bbox (line strikes through text)
90
+
91
+ ```python
92
+ issues = lint_drawing([dim1, dim2, lea1])
93
+ for issue in issues:
94
+ print(issue.severity, issue.message)
95
+ ```
96
+
97
+ ---
98
+
99
+ ### `iso_title_block(...)` and `surface_finish_mark(...)`
100
+
101
+ `iso_title_block` is a **standalone title box** (170 × 16 mm by default), positioned by the caller. It is *not* a substitute for `build123d.TechnicalDrawing`, which is a whole-page chrome — page-sized border + grid ticks + embedded title box, returned as a single `Sketch`. Use `TechnicalDrawing` when you want the full drawing-sheet frame; reach for `iso_title_block` when you want just the title box, positionable anywhere, with separate `lines`/`text` `Compound`s for SVG layer routing, and with `material` / `general_tolerance` fields that `TechnicalDrawing` does not carry.
102
+
103
+ `surface_finish_mark` produces an ISO 1302 Ra-value check-mark symbol — build123d does not ship one.
104
+
105
+ ## Status against upstream
106
+
107
+ - `lint_drawing` is a prototype of rule-based drawing checks that build123d's roadmap mentions as future work. If upstream ships its own linter later, this one can be deprecated.
108
+ - `dim_linear` is a thin convenience wrapper over `ExtensionLine` — it does not replace the underlying class, it just lets you write `side="above"` instead of computing the right-hand-normal signed offset by hand. If upstream adds a named-side parameter, this helper becomes redundant.
109
+
110
+ ## Development
111
+
112
+ ```
113
+ git clone https://github.com/pzfreo/build123d-drafting-helpers.git
114
+ cd build123d-drafting-helpers
115
+ uv run pytest tests/
116
+ ```
117
+
118
+ ## Status
119
+
120
+ Alpha. API may change. Developed alongside [build123d-mcp](https://github.com/pzfreo/build123d-mcp), which integrates these helpers into its LLM-facing drawing workflow.