Skip to content

armgit / SOMA

Public Imported from GitHub
0

Desktop app for designing parametric 3D models in CadQuery together with the coding agent of your choice

soma: Normteile mit soma.fasteners und Rolle hardware (E48)

Kai-Jungsthoefel7e4a5ce8fe6d
diff --git a/python/pyproject.toml b/python/pyproject.toml
index 5e00ab5..fef62b8 100644
--- a/python/pyproject.toml
+++ b/python/pyproject.toml
@@ -14,3 +14,7 @@ soma = "soma.cli:main"
[tool.setuptools]
packages = ["soma"]
+
+[tool.setuptools.package-data]
+# Masstabellen der Normteile (aus bd_warehouse, Apache 2.0)
+soma = ["data/fasteners/*"]
diff --git a/python/soma/__init__.py b/python/soma/__init__.py
index 9ea87da..c50311b 100644
--- a/python/soma/__init__.py
+++ b/python/soma/__init__.py
@@ -1,4 +1,5 @@
-"""soma: Hilfsbibliothek von SOMA. Aus model.py: `from soma import add_part, import_step`."""
+"""soma: Hilfsbibliothek von SOMA. Aus model.py: `from soma import add_part, import_step`.
+Normteile (Schrauben, Muttern, Scheiben, Gewindeeinsaetze): `from soma.fasteners import Screw, Nut, Washer, HeatSetInsert`."""
from .registry import add_part, import_assembly, import_step
__version__ = "0.1.0"
diff --git a/python/soma/cli.py b/python/soma/cli.py
index 43da01e..b160d31 100644
--- a/python/soma/cli.py
+++ b/python/soma/cli.py
@@ -75,7 +75,11 @@ def cmd_export(args):
print(f"Export nicht moeglich, das Modell laesst sich nicht bauen: {e.message}", file=sys.stderr)
return 1
if args.all:
- chosen = [p for p in parts if p["role"] != "reference"] # Referenzteile sind nicht Teil von --all (E34)
+ # Referenzen (E34) und Zukaufteile wie Schrauben (E48) gehoeren nicht zu --all, einzeln gehen sie
+ chosen = [p for p in parts if p["role"] not in ("reference", "hardware")]
+ skipped = len(parts) - len(chosen)
+ if skipped:
+ print(f"nicht exportiert: {skipped} Referenz- und Zukaufteil(e)")
else:
chosen = [p for p in parts if p["name"] == args.part or p["step_name"] == args.part]
if not chosen:
@@ -129,7 +133,7 @@ def main(argv=None):
e = sub.add_parser("export", help="Einzelne Bauteile exportieren")
g = e.add_mutually_exclusive_group(required=True)
g.add_argument("part", nargs="?", help="Name des Bauteils")
- g.add_argument("--all", action="store_true", help="alle Bauteile (ohne Referenzteile)")
+ g.add_argument("--all", action="store_true", help="alle Bauteile (ohne Referenz- und Zukaufteile)")
e.add_argument("--format", required=True, help=", ".join(EXPORT_FORMATS))
e.add_argument("--out", help="Zielordner relativ zum Projekt (Standard: exports)")
e.add_argument("--project", default=".")
diff --git a/python/soma/data/fasteners/LICENSE-bd_warehouse.txt b/python/soma/data/fasteners/LICENSE-bd_warehouse.txt
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/python/soma/data/fasteners/LICENSE-bd_warehouse.txt
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/python/soma/data/fasteners/QUELLE.md b/python/soma/data/fasteners/QUELLE.md
new file mode 100644
index 0000000..5237461
--- /dev/null
+++ b/python/soma/data/fasteners/QUELLE.md
@@ -0,0 +1,35 @@
+# Herkunft der Maßtabellen
+
+Die CSV-Dateien in diesem Ordner stammen unverändert aus **bd_warehouse** von Gumyr
+(https://github.com/gumyr/bd_warehouse, Ordner `src/bd_warehouse/data/`, Stand Commit
+`eed2da118da99007ad2d3904466ac0b24964f84d` vom 21.09.2026, Version 0.3.0).
+
+Lizenz: Apache License 2.0, Text in `LICENSE-bd_warehouse.txt`. Copyright 2024 Gumyr.
+
+Verwendet von `soma/fasteners.py`. Der Code dort ist eigener Code und übernimmt nichts aus bd_warehouse.
+
+| Datei | Inhalt |
+|---|---|
+| `socket_head_cap_parameters.csv` | ISO 4762 |
+| `button_head_parameters.csv` | ISO 7380-1 |
+| `countersunk_head_parameters.csv` | ISO 10642 (weitere Senkschrauben ungenutzt) |
+| `hex_head_parameters.csv` | ISO 4017, ISO 4014, DIN 931 |
+| `setscrew_parameters.csv` | ISO 4026 |
+| `hex_nut_parameters.csv` | ISO 4032, ISO 4033, ISO 4035 |
+| `square_nut_parameters.csv` | DIN 557 |
+| `plain_washer_parameters.csv` | ISO 7089, ISO 7091, ISO 7093 |
+| `clearance_hole_sizes.csv` | Durchgangslöcher (Close, Normal, Loose = ISO 273 fein, mittel, grob) |
+| `tap_hole_sizes.csv` | Kernlöcher (genutzt: Spalte Soft) |
+| `nominal_screw_lengths.csv` | Normlängen je Schraubennorm |
+| `heatset_nut_parameters.csv` | Gewindeeinsätze von ruthex, CNC Kitchen, McMaster-Carr, Hilitchi, AE-SamZhihui |
+| `drill_sizes.csv` | Zollbohrer (Nummern und Buchstaben) für die Bohrungen der Gewindeeinsätze |
+
+Bekannte Eigenheiten der Daten:
+
+- Die Werte sind teils Nennmaße, teils Größtmaße (ISO 4762 M3: Kopf 5,68 mm, also das Größtmaß mit Rändelung).
+- Die Bohrungen der Gewindeeinsätze sind Zollbohrer und weichen etwas von den metrischen Richtwerten im Skill
+ „3D-Druck“ ab (ruthex M3: 4,04 statt 4,0 mm, M5: 6,53 statt 6,4 mm). Gegen Herstellerblätter geprüft ist das nicht.
+- Für die M10-Einsätze von ruthex und CNC Kitchen steht als Bohrer „M14“, mehr als der Einsatz dick ist. `soma`
+ lehnt diese Einsätze mit einer Meldung ab.
+- Bei ISO 4035 M3 steht die Zeile unter der Steigung 0,45 statt 0,5. `soma` nimmt dann die vorhandene Zeile, denn ohne
+ Gewinde zählt nur der Durchmesser.
diff --git a/python/soma/data/fasteners/button_head_parameters.csv b/python/soma/data/fasteners/button_head_parameters.csv
new file mode 100644
index 0000000..e58acd4
--- /dev/null
+++ b/python/soma/data/fasteners/button_head_parameters.csv
@@ -0,0 +1,9 @@
+Size,iso7380_1:dk,iso7380_1:dl,iso7380_1:k,iso7380_1:rf,iso7380_1:s,iso7380_1:t,iso7380_1:short,iso7380_1:long
+M3-0.5,5.7,2.6,1.65,3.7,2.08,1.04,6,30
+M4-0.7,7.6,3.8,2.2,4.6,2.58,1.3,6,40
+M5-0.8,9.5,5,2.75,5.75,3.08,1.56,8,50
+M6-1,10.5,6,3.3,6.15,4.095,2.08,10,60
+M8-1.25,14,7.7,4.4,7.95,5.14,2.6,12,80
+M10-1.5,17.5,10,5.5,9.8,6.14,3.12,16,100
+M12-1.75,21,12,6.6,11.2,8.175,4.16,20,100
+M16-2,28,16,8.8,15.3,10.175,5.2,25,100
diff --git a/python/soma/data/fasteners/clearance_hole_sizes.csv b/python/soma/data/fasteners/clearance_hole_sizes.csv
new file mode 100644
index 0000000..376b7fc
--- /dev/null
+++ b/python/soma/data/fasteners/clearance_hole_sizes.csv
@@ -0,0 +1,91 @@
+Size,Close,Normal,Loose
+M1,1.1,1.2,1.3
+M1.2,1.3,1.4,1.5
+M1.4,1.5,1.6,1.8
+M1.6,1.7,1.8,2
+M1.8,2,2.1,2.2
+M2,2.2,2.4,2.6
+M2.5,2.7,2.9,3.1
+M3,3.2,3.4,3.6
+M3.5,3.7,3.9,4.2
+M4,4.3,4.5,4.8
+M5,5.3,5.5,5.8
+M6,6.4,6.6,7
+M7,7.4,7.6,8
+M8,8.4,9,10
+M9,9.45,10,11
+M10,10.5,11,12
+M12,13,14,15
+M14,15,16,17
+M15,16,17,18
+M16,17,18,19
+M17,18,19,20
+M18,19,20,21
+M20,21,22,24
+M22,23,24,26
+M24,25,26,28
+M25,26,27,29
+M27,28,30,32
+M28,29,31,33
+M30,31,33,35
+M32,33,35,37
+M33,34,36,38
+M36,37,39,42
+M39,40,42,45
+M42,43,45,48
+M45,46,48,52
+M48,50,52,56
+M52,54,56,62
+M56,58,62,66
+M60,62,66,70
+M64,66,70,74
+M68,70,74,78
+M72,74,78,82
+M76,78,82,86
+M80,82,86,91
+M85,87,91,96
+M90,93,96,101
+M95,98,101,107
+M100,104,107,112
+M105,109,112,117
+M110,114,117,122
+M115,119,122,127
+M120,124,127,132
+M125,129,132,137
+M130,134,137,144
+M140,144,147,155
+M150,155,158,165
+#0,#51,#48,3/32
+#1,#46,#43,#37
+#2,3/32,#38,#32
+#3,#36,#32,#30
+#4,#31,#30,#27
+#5,9/64,5/32,11/64
+#6,#23,#18,#13
+#8,#15,#9,#3
+#10,#5,#2,B
+#12,0.221,0.228,0.246
+1/4,17/64,9/32,19/64
+5/16,21/64,11/32,23/64
+3/8,25/64,13/32,27/64
+7/16,29/64,15/32,31/64
+1/2,17/32,9/16,39/64
+9/16,0.5781,0.5937,0.6094
+5/8,21/32,11/16,47/64
+3/4,25/32,13/16,29/32
+7/8,29/32,15/16,1 1/32
+1,1 1/32,1 3/32,1 5/32
+1 1/8,1 5/32,1 7/32,1 5/16
+1 1/4,1 9/32,1 11/32,1 7/16
+1 3/8,1 7/16,1 1/2,1 39/64
+1 1/2,1 9/16,1 5/8,1 47/64
+1-3/4,1.7656,1.7812,1.7969
+2,2.0156,2.0312,2.0469
+2-1/4,2.2656,2.2812,2.2969
+2-1/2,2.5156,2.5312,2.5469
+2-3/4,2.7656,2.7812,2.7969
+3,3.0156,3.0312,3.0469
+3-1/4,3.2656,3.2812,3.2969
+3-1/2,3.5156,3.5312,3.5469
+3-3/4,3.7656,3.7812,3.7969
+4,4.0156,4.0312,4.0469
diff --git a/python/soma/data/fasteners/countersunk_head_parameters.csv b/python/soma/data/fasteners/countersunk_head_parameters.csv
new file mode 100644
index 0000000..1ba35d9
--- /dev/null
+++ b/python/soma/data/fasteners/countersunk_head_parameters.csv
@@ -0,0 +1,51 @@
+Size,iso10642:a,iso10642:dk ,iso10642:k,iso10642:s,iso10642:t,iso10642:short,iso10642:long,iso14581:a,iso14581:dk,iso14581:k,iso14581:recess,iso14581:short,iso14581:long,iso14582:a,iso14582:dk,iso14582:k,iso14582:recess,iso14582:short,iso14582:long,iso2009:a,iso2009:b,iso2009:dk,iso2009:k,iso2009:n,iso2009:t,iso2009:short,iso2009:long,iso7046:a,iso7046:dk,iso7046:k,iso7046:recess,iso7046:short,iso7046:long
+M1-0.25,,,,,,,,,,,,,,,,,,,,90,0,1.9,0.6,0.31,0.3,2,5,,,,,,
+M1.2-0.25,,,,,,,,,,,,,,,,,,,,90,0,2.3,0.72,0.36,0.35,2,6,,,,,,
+M1.4-0.3,,,,,,,,,,,,,,,,,,,,90,0,2.6,0.86,0.36,0.4,2,10,,,,,,
+M1.5-0.35,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M1.6-0.35,,,,,,,,,,,,,,,,,,,,90,15,3,0.96,0.46,0.45,2,10,90,3,0.96,PH0,3,16
+M1.8-0.35,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M2-0.4,,,,,,,,90,4.4,1.2,T6,3,20,,,,,,,90,16,3.8,1.2,0.56,0.6,3,18,90,3.8,1.2,PH0,3,20
+M2-0.45,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M2.2-0.45,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M2.5-0.45,,,,,,,,90,5.5,1.5,T8,3,25,,,,,,,90,18,4.7,1.5,0.66,0.7,3,25,90,4.7,1.5,PH1,3,25
+M3-0.5,90,6,1.7,2.1,1.2,8,30,90,6.3,1.65,T10,4,30,90,6.5,2.2,T10,8,30,90,19,5.6,1.65,0.86,0.85,4,30,90,5.6,1.65,PH1,4,30
+M3-0.6,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M3.5-0.6,,,,,,,,90,8.2,2.35,T15,5,35,,,,,,,90,20,6.5,1.93,0.96,1,4,35,90,6.5,1.93,PH2,5,35
+M4-0.7,90,8,2.3,2.6,1.8,8,40,90,9.4,2.7,T20,5,40,90,9,3.01,T20,8,40,90,22,7.5,2.2,1.06,1.1,5,40,90,7.5,2.2,PH2,5,40
+M4-0.75,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M4.5-0.75,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M5-0.8,90,10,2.8,3.1,2.3,8,50,90,10.4,2.7,T25,6,50,90,10.8,3.5,T25,8,50,90,25,9.2,2.5,1.26,1.3,6,50,90,9.2,2.5,PH2,6,50
+M5-0.9,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M5-1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M5.5-0.9,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M6-0.75,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M6-1,90,12,3.3,4.12,2.5,8,60,90,12.6,3.3,T30,8,50,90,13.1,4.22,T30,8,60,90,28,11,3,1.66,1.6,8,50,90,11,3,PH3,8,60
+M7-0.75,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M7-1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M8-1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M8-1.25,90,16,4.4,5.14,3.5,10,80,90,17.3,4.65,T45,10,60,90,17.8,5.69,T45,10,80,90,34,14.5,4,2.06,2.1,10,55,90,14.5,4,PH4,10,60
+M9-1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M9-1.25,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M10-1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M10-1.25,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M10-1.5,90,20,5.5,6.14,4.4,12,100,90,20,5,T50,12,60,90,21.1,6.5,T50,12,100,90,40,18,5,2.56,2.6,12,60,90,18,5,PH4,12,60
+M11-1.5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M12-1.25,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M12-1.5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M12-1.75,90,24,6.5,8.175,4.6,20,100,,,,,,,,,,,,,90,46,22,6,3.06,3,20,80,,,,,,
+M14-1.25,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M14-1.5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M14-2,90,27,7,10.175,4.8,25,100,,,,,,,,,,,,,90,52,25,7,3.06,3.5,22,80,,,,,,
+M15-1.5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M16-1.5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M16-2,90,30,7.5,10.175,5.3,30,100,,,,,,,,,,,,,90,58,29,8,4.07,4,25,100,,,,,,
+M17-1.5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M18-1.5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M18-2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M18-2.5,90,33,8,12.212,5.5,35,100,,,,,,,,,,,,,90,64,33,9,4.07,4.5,28,100,,,,,,
+M19-2.5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M20-1.5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M20-2.5,90,36,8.5,12.212,5.9,35,100,,,,,,,,,,,,,90,70,36,10,5.07,5,30,100,,,,,,
+M22-2.5,60,36,13.1,14.212,8.8,40,100,,,,,,,,,,,,,,,,,,,,,,,,,,
+M24-3,60,39,14,14.212,10.3,50,110,,,,,,,,,,,,,,,,,,,,,,,,,,
diff --git a/python/soma/data/fasteners/drill_sizes.csv b/python/soma/data/fasteners/drill_sizes.csv
new file mode 100644
index 0000000..f6e5bcc
--- /dev/null
+++ b/python/soma/data/fasteners/drill_sizes.csv
@@ -0,0 +1,107 @@
+Size,Diameter
+A, 0.234
+B, 0.238
+C, 0.242
+D, 0.246
+E, 0.250
+F, 0.257
+G, 0.261
+H, 0.266
+I, 0.272
+J, 0.277
+K, 0.281
+L, 0.290
+M, 0.295
+N, 0.302
+O, 0.316
+P, 0.323
+Q, 0.332
+R, 0.339
+S, 0.348
+T, 0.358
+U, 0.368
+V, 0.377
+W, 0.386
+X, 0.397
+Y, 0.404
+Z, 0.413
+#1, 0.228
+#2, 0.221
+#3, 0.213
+#4, 0.209
+#5, 0.205
+#6, 0.204
+#7, 0.201
+#8, 0.199
+#9, 0.196
+#10, 0.193
+#11, 0.191
+#12, 0.189
+#13, 0.185
+#14, 0.182
+#15, 0.18
+#16, 0.177
+#17, 0.173
+#18, 0.17
+#19, 0.166
+#20, 0.161
+#21, 0.159
+#22, 0.157
+#23, 0.154
+#24, 0.152
+#25, 0.15
+#26, 0.147
+#27, 0.144
+#28, 0.14
+#29, 0.136
+#30, 0.1285
+#31, 0.12
+#32, 0.116
+#33, 0.113
+#34, 0.111
+#35, 0.11
+#36, 0.1065
+#37, 0.104
+#38, 0.1015
+#39, 0.0995
+#40, 0.098
+#41, 0.096
+#42, 0.0935
+#43, 0.089
+#44, 0.086
+#45, 0.082
+#46, 0.081
+#47, 0.0785
+#48, 0.076
+#49, 0.073
+#50, 0.07
+#51, 0.067
+#52, 0.0635
+#53, 0.0595
+#54, 0.055
+#55, 0.052
+#56, 0.0465
+#57, 0.043
+#58, 0.042
+#59, 0.041
+#60, 0.04
+#61, 0.039
+#62, 0.038
+#63, 0.037
+#64, 0.036
+#65, 0.035
+#66, 0.033
+#67, 0.032
+#68, 0.031
+#69, 0.029
+#70, 0.028
+#71, 0.026
+#72, 0.025
+#73, 0.024
+#74, 0.0225
+#75, 0.021
+#76, 0.02
+#77, 0.018
+#78, 0.016
+#79, 0.0145
+#80, 0.0135
diff --git a/python/soma/data/fasteners/heatset_nut_parameters.csv b/python/soma/data/fasteners/heatset_nut_parameters.csv
new file mode 100644
index 0000000..14889da
--- /dev/null
+++ b/python/soma/data/fasteners/heatset_nut_parameters.csv
@@ -0,0 +1,147 @@
+Size,McMaster-Carr:s,McMaster-Carr:m,McMaster-Carr:dc,McMaster-Carr:knurls,McMaster-Carr:material_thickness,McMaster-Carr:drill,McMaster-Carr:part,Hilitchi:s,Hilitchi:m,Hilitchi:dc,Hilitchi:knurls,Hilitchi:material_thickness,Hilitchi:drill,Hilitchi:part,AE-SamZhihui:s,AE-SamZhihui:m,AE-SamZhihui:dc,AE-SamZhihui:knurls,AE-SamZhihui:material_thickness,AE-SamZhihui:drill,AE-SamZhihui:part,ruthex:s,ruthex:m,ruthex:dc,ruthex:knurls,ruthex:material_thickness,ruthex:drill,ruthex:part,CNCKitchen:s,CNCKitchen:m,CNCKitchen:dc,CNCKitchen:knurls,CNCKitchen:material_thickness,CNCKitchen:drill,CNCKitchen:part
+M2-0.4-Short,3.6,2.5,3.1,20,3.3,#30, 94459A110,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M2-0.4-Standard,3.6,4,3.1,20,4.7,#30, 94459A120,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M3-0.5-Short,4.7,4.3,3.9,20,5.1,#21, 94459A130,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M3-0.5-Standard,4.7,5.7,3.9,20,6.5,#21, 94459A140,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M4-0.7-Short,6.3,4.7,5.5,20,5.5,#2, 94459A150,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M4-0.7-Standard,6.3,8.2,5.5,20,8.9,#2, 94459A170,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M5-0.8-Standard,7.1,9.5,6.3,20,10.3, F, 94459A180,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+M2-0.4-3,,,,,,,,3.5,3,2.9,20,3.8,#30,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M2-0.4-4,,,,,,,,3.5,4,2.9,20,4.8,#30,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M2-0.4-6,,,,,,,,3.5,6,2.9,20,6.8,#30,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M2-0.4-8,,,,,,,,3.5,8,2.9,20,8.8,#30,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M3-0.5-6,,,,,,,,5,6,4.3,20,6.8,#21,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M3-0.5-8,,,,,,,,5,8,4.3,20,8.8,#21,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M3-0.5-10,,,,,,,,5,10,4.3,20,10.8,#21,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M4-0.7-8,,,,,,,,6,8,5.3,20,8.8,#2,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M4-0.7-6,,,,,,,,6,6,5.3,20,6.8,#2,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M4-0.7-10,,,,,,,,6,10,5.3,20,10.8,#2,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M5-0.8-6,,,,,,,,7,6,6.3,20,6.8,F,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M5-0.8-8,,,,,,,,7,8,6.3,20,8.8,F,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M5-0.8-10,,,,,,,,7,10,6.3,20,10.8,F,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M6-1-10,,,,,,,,8,10,7.3,20,10.8,M,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M6-1-12,,,,,,,,8,12,7.3,20,12.8,M,H-THM300,,,,,,,,,,,,,,,,,,,,,
+M1.4-0.3-H1.5-D2.3,,,,,,,,,,,,,,,2.3,1.5,1.9,20,0,#47,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M1.4-0.3-H2-D2.3,,,,,,,,,,,,,,,2.3,2,1.9,20,0,#47,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M1.4-0.3-H3-D2.3,,,,,,,,,,,,,,,2.3,3,1.9,20,0,#47,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M1.4-0.3-H4-D2.3,,,,,,,,,,,,,,,2.3,4,1.9,20,0,#47,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M1.4-0.3-H5-D2.3,,,,,,,,,,,,,,,2.3,5,1.9,20,0,#47,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M1.4-0.3-H6-D2.3,,,,,,,,,,,,,,,2.3,6,1.9,20,0,#47,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M1.6-0.35-H2-D2.5,,,,,,,,,,,,,,,2.5,2,2,20,0,#45,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M1.6-0.35-H3-D2.5,,,,,,,,,,,,,,,2.5,3,2,20,0,#45,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M1.6-0.35-H4-D2.5,,,,,,,,,,,,,,,2.5,4,2,20,0,#45,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M1.6-0.35-H5-D2.5,,,,,,,,,,,,,,,2.5,5,2,20,0,#45,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M1.6-0.35-H6-D2.5,,,,,,,,,,,,,,,2.5,6,2,20,0,#45,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H2-D3,,,,,,,,,,,,,,,3,2,2.68,20,0,#35,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H3-D3,,,,,,,,,,,,,,,3,3,2.68,20,0,#35,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H4-D3,,,,,,,,,,,,,,,3,4,2.68,20,0,#35,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H5-D3,,,,,,,,,,,,,,,3,5,2.68,20,0,#35,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H6-D3,,,,,,,,,,,,,,,3,6,2.68,20,0,#35,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H8-D3,,,,,,,,,,,,,,,3,8,2.68,20,0,#35,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H2-D3.2,,,,,,,,,,,,,,,3.2,2,2.81,20,0,#32,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H3-D3.2,,,,,,,,,,,,,,,3.2,3,2.81,20,0,#33,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H4-D3.2,,,,,,,,,,,,,,,3.2,4,2.81,20,0,#34,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H5-D3.2,,,,,,,,,,,,,,,3.2,5,2.81,20,0,#35,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H6-D3.2,,,,,,,,,,,,,,,3.2,6,2.81,20,0,#36,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H8-D3.2,,,,,,,,,,,,,,,3.2,8,2.81,20,0,#37,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H2-D3.5,,,,,,,,,,,,,,,3.5,2,3.03,20,0,#30,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H3-D3.5,,,,,,,,,,,,,,,3.5,3,3.03,20,0,#30,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H4-D3.5,,,,,,,,,,,,,,,3.5,4,3.03,20,0,#30,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H5-D3.5,,,,,,,,,,,,,,,3.5,5,3.03,20,0,#30,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-H6-D3.5,,,,,,,,,,,,,,,3.5,6,3.03,20,0,#30,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H2-D3.5,,,,,,,,,,,,,,,3.5,2,3.04,20,0,#30,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H3-D3.5,,,,,,,,,,,,,,,3.5,3,3.04,20,0,#30,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H4-D3.5,,,,,,,,,,,,,,,3.5,4,3.04,20,0,#30,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H5-D3.5,,,,,,,,,,,,,,,3.5,5,3.04,20,0,#30,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H6-D3.5,,,,,,,,,,,,,,,3.5,6,3.04,20,0,#30,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H7-D3.5,,,,,,,,,,,,,,,3.5,7,3.04,20,0,#30,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H8-D3.5,,,,,,,,,,,,,,,3.5,8,3.04,20,0,#30,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H2-D4,,,,,,,,,,,,,,,4,2,3.44,20,0,#28,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H3-D4,,,,,,,,,,,,,,,4,3,3.44,20,0,#28,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H4-D4,,,,,,,,,,,,,,,4,4,3.44,20,0,#28,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H5-D4,,,,,,,,,,,,,,,4,5,3.44,20,0,#28,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H6-D4,,,,,,,,,,,,,,,4,6,3.44,20,0,#28,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H7-D4,,,,,,,,,,,,,,,4,7,3.44,20,0,#28,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H8-D4,,,,,,,,,,,,,,,4,8,3.44,20,0,#28,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2.5-0.45-H8-D4,,,,,,,,,,,,,,,4,8,3.44,20,0,#28,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H3-D4.2,,,,,,,,,,,,,,,4.2,3,3.74,20,0,#24,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H4-D4.2,,,,,,,,,,,,,,,4.2,4,3.74,20,0,#25,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H5-D4.2,,,,,,,,,,,,,,,4.2,5,3.74,20,0,#26,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H6-D4.2,,,,,,,,,,,,,,,4.2,6,3.74,20,0,#27,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H7-D4.2,,,,,,,,,,,,,,,4.2,7,3.74,20,0,#28,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H8-D4.2,,,,,,,,,,,,,,,4.2,8,3.74,20,0,#29,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H9-D4.2,,,,,,,,,,,,,,,4.2,9,3.74,20,0,#30,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H10-D4.2,,,,,,,,,,,,,,,4.2,10,3.74,20,0,#31,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H3-D4.5,,,,,,,,,,,,,,,4.5,3,3.9,20,0,#22,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H4-D4.5,,,,,,,,,,,,,,,4.5,4,3.9,20,0,#22,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H5-D4.5,,,,,,,,,,,,,,,4.5,5,3.9,20,0,#22,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H6-D4.5,,,,,,,,,,,,,,,4.5,6,3.9,20,0,#22,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H7-D4.5,,,,,,,,,,,,,,,4.5,7,3.9,20,0,#22,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H8-D4.5,,,,,,,,,,,,,,,4.5,8,3.9,20,0,#22,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H9-D4.5,,,,,,,,,,,,,,,4.5,9,3.9,20,0,#22,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H10-D4.5,,,,,,,,,,,,,,,4.5,10,3.9,20,0,#22,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H3-D5,,,,,,,,,,,,,,,5,3,4.17,20,0,#18,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H4-D5,,,,,,,,,,,,,,,5,4,4.17,20,0,#18,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H5-D5,,,,,,,,,,,,,,,5,5,4.17,20,0,#18,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H6-D5,,,,,,,,,,,,,,,5,6,4.17,20,0,#18,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H7-D5,,,,,,,,,,,,,,,5,7,4.17,20,0,#18,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H8-D5,,,,,,,,,,,,,,,5,8,4.17,20,0,#18,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H9-D5,,,,,,,,,,,,,,,5,9,4.17,20,0,#18,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M3-0.5-H10-D5,,,,,,,,,,,,,,,5,10,4.17,20,0,#18,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M4-0.7-H4-D6,,,,,,,,,,,,,,,6,4,5.33,20,0,#3,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M4-0.7-H5-D6,,,,,,,,,,,,,,,6,5,5.33,20,0,#3,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M4-0.7-H6-D6,,,,,,,,,,,,,,,6,6,5.33,20,0,#3,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M4-0.7-H7-D6,,,,,,,,,,,,,,,6,7,5.33,20,0,#3,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M4-0.7-H8-D6,,,,,,,,,,,,,,,6,8,5.33,20,0,#3,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M4-0.7-H9-D6,,,,,,,,,,,,,,,6,9,5.33,20,0,#3,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M4-0.7-H10-D6,,,,,,,,,,,,,,,6,10,5.33,20,0,#3,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M4-0.7-H12-D6,,,,,,,,,,,,,,,6,12,5.33,20,0,#3,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H4-D7,,,,,,,,,,,,,,,7,4,6.12,20,0,D,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H5-D7,,,,,,,,,,,,,,,7,5,6.12,20,0,D,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H6-D7,,,,,,,,,,,,,,,7,6,6.12,20,0,D,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H7-D7,,,,,,,,,,,,,,,7,7,6.12,20,0,D,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H8-D7,,,,,,,,,,,,,,,7,8,6.12,20,0,D,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H9-D7,,,,,,,,,,,,,,,7,9,6.12,20,0,D,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H10-D7,,,,,,,,,,,,,,,7,10,6.12,20,0,D,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H11-D7,,,,,,,,,,,,,,,7,11,6.12,20,0,D,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H12-D7,,,,,,,,,,,,,,,7,12,6.12,20,0,D,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H5-D8,,,,,,,,,,,,,,,8,5,6.97,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H6-D8,,,,,,,,,,,,,,,8,6,6.97,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H7-D8,,,,,,,,,,,,,,,8,7,6.97,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H8-D8,,,,,,,,,,,,,,,8,8,6.97,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H9-D8,,,,,,,,,,,,,,,8,9,6.97,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M5-0.8-H10-D8,,,,,,,,,,,,,,,8,10,6.97,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M6-1-H4-D8,,,,,,,,,,,,,,,8,4,7.09,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M6-1-H5-D8,,,,,,,,,,,,,,,8,5,7.09,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M6-1-H6-D8,,,,,,,,,,,,,,,8,6,7.09,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M6-1-H7-D8,,,,,,,,,,,,,,,8,7,7.09,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M6-1-H8-D8,,,,,,,,,,,,,,,8,8,7.09,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M6-1-H9-D8,,,,,,,,,,,,,,,8,9,7.09,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M6-1-H10-D8,,,,,,,,,,,,,,,8,10,7.09,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M6-1-H11-D8,,,,,,,,,,,,,,,8,11,7.09,20,0,K,https://www.aliexpress.com/item/1005005220632314.html,,,,,,,,,,,,,,
+M2-0.4-4,,,,,,,,,,,,,,,,,,,,,,3.6,4.0,3.2,12,1.3,#30,GE-M2x04-001,,,,,,,
+M2.5-0.45-5.7,,,,,,,,,,,,,,,,,,,,,,4.6,5.7,3.9,18,1.6,#23,GE-M25x57-001,,,,,,,
+M3-0.5-5.7,,,,,,,,,,,,,,,,,,,,,,4.6,5.7,4.0,18,1.6,#21,GE-M3x57-001,,,,,,,
+M3-0.5-4.0,,,,,,,,,,,,,,,,,,,,,,4.6,4.0,4.0,18,1.6,#21,GE-M3Sx40-002,,,,,,,
+M3-0.5-4.0Voron,,,,,,,,,,,,,,,,,,,,,,5.0,4.0,4.4,12,1.3,#16,GE-M3x5x4-001,,,,,,,
+M4-0.7-8.1,,,,,,,,,,,,,,,,,,,,,,6.3,8.1,5.6,15,2.1,#2,GE-M4x81-001,,,,,,,
+M4-0.7-4.0,,,,,,,,,,,,,,,,,,,,,,6.3,4.0,5.6,15,2.1,#2,GE-M4Sx04-1,,,,,,,
+M5-0.8-9.5,,,,,,,,,,,,,,,,,,,,,,7.1,9.5,6.4,21,2.6,F,GE-M5x95-001,,,,,,,
+M5-0.8-5.8,,,,,,,,,,,,,,,,,,,,,,7.1,5.8,6.4,21,2.6,F,GE-M5Sx58-001,,,,,,,
+M6-1-12.7,,,,,,,,,,,,,,,,,,,,,,8.7,12.7,8.0,21,3.3,O,GE-M6x127-002,,,,,,,
+M6-1-6.8,,,,,,,,,,,,,,,,,,,,,,8.7,6.8,8.0,21,3.3,O,GE-M6x68-001,,,,,,,
+M8-1.25-12.7,,,,,,,,,,,,,,,,,,,,,,10.1,12.7,9.6,30,4.5,W,GE-M8x127-001,,,,,,,
+M10-1.5-12.7,,,,,,,,,,,,,,,,,,,,,,12.6,12.7,12.0,30,6.0,M14,GE-M10x127-001,,,,,,,
+M1.6-0.35-2.5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2.5,1.6,2.2,20,1.3,#39,4262391012598 (https://cnckitchen.store/products/heat-set-insert-m1-6-100-pieces-kopie)
+M2-0.4-3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,3.6,3.0,3.2,16,1.3,#30,4262391010013 (https://cnckitchen.store/products/heat-set-insert-m2-x-3-100-pieces)
+M2.5-0.45-4,,,,,,,,,,,,,,,,,,,,,,,,,,,,,4.6,4.0,4.0,16,1.6,#20,4262391011980 (https://cnckitchen.store/products/gewindeeinsatz-threaded-insert-m2-5-standard-100-stk-pcs)
+M3-0.5-3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,4.6,3.0,4.0,16,1.6,#20,4270002316416 (https://cnckitchen.store/products/heat-set-insert-m3-x-3-short-version-100-pieces)
+M3-0.5-5.7,,,,,,,,,,,,,,,,,,,,,,,,,,,,,4.6,5.7,4.0,16,1.6,#20,4270002316409 (https://cnckitchen.store/products/heat-set-insert-m3-x-5-7-100-pieces)
+M3-0.5-4,,,,,,,,,,,,,,,,,,,,,,,,,,,,,5.0,4.0,4.4,10,1.6,#16,4262391010051 (https://cnckitchen.store/products/made-for-voron-gewindeeinsatz-threaded-insert-m3x5x4-100-stk-pcs)
+M4-0.7-4,,,,,,,,,,,,,,,,,,,,,,,,,,,,,6.3,4.0,5.7,18,2.1,#1,4270002316430 (https://cnckitchen.store/products/heat-set-insert-m4-x-4-short-version-100-pieces)
+M4-0.7-8.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,6.3,8.1,5.7,18,2.1,#1,4270002316423 (https://cnckitchen.store/products/heat-set-insert-m4-x-8-1-50-pieces)
+M5-0.8-5.8,,,,,,,,,,,,,,,,,,,,,,,,,,,,,7.1,5.8,6.5,20,2.6,F,4270002316454 (https://cnckitchen.store/products/heat-set-insert-m5-x-5-8-short-version-50-pieces)
+M5-0.8-9.5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,7.1,9.5,6.5,20,2.6,F,4270002316447 (https://cnckitchen.store/products/heat-set-insert-m5-x-9-5-50-pieces)
+M6-1-12.7,,,,,,,,,,,,,,,,,,,,,,,,,,,,,8.7,12.7,8.1,25,3.3,P,4262391010020 (https://cnckitchen.store/products/heat-set-insert-m6-x-12-7-20-pieces)
+M8-1.25-12.7,,,,,,,,,,,,,,,,,,,,,,,,,,,,,10.2,12.7,9.7,25,4.5,W,4262391010044 (https://cnckitchen.store/products/heat-set-insert-m8-x-12-7-20-pieces)
+M10-1.5-12.7,,,,,,,,,,,,,,,,,,,,,,,,,,,,,12.6,12.7,12.0,28,6.0,M14,4262391011744 (https://cnckitchen.store/products/heat-set-insert-m10-x-12-7-20-pieces)
diff --git a/python/soma/data/fasteners/hex_head_parameters.csv b/python/soma/data/fasteners/hex_head_parameters.csv
new file mode 100644
index 0000000..acb3091
--- /dev/null
+++ b/python/soma/data/fasteners/hex_head_parameters.csv
@@ -0,0 +1,30 @@
+Size,din931:k,din931:s,din931:short,din931:long,iso4014:k,iso4014:s,iso4014:short,iso4014:long,iso4017:k,iso4017:s,iso4017:short,iso4017:long
+M1.6-0.35,1.1,3.02,12,16,1.3,3.2,12,16,1.3,3.2,2,16
+M2-0.4,1.4,3.82,16,20,1.6,4,16,20,1.6,4,4,20
+M2.5-0.45,1.7,4.82,16,25,1.9,5,16,25,1.9,5,5,25
+M3-0.5,2,5.5,20,30,2,5.5,20,30,2.2,5.5,5,30
+M3.5-0.6,2.4,5.82,25,35,2.6,6,20,35,2.6,6,8,35
+M4-0.7,2.8,7,25,40,2.8,7,25,40,3,7,6,40
+M5-0.8,3.5,8,25,50,3.5,8,25,50,3.74,8,8,50
+M6-1,4,10,30,60,4,10,30,60,4.24,10,12,60
+M8-1.25,5.3,13,35,80,5.3,13,40,80,5.54,13,16,80
+M10-1.5,6.4,17,40,100,6.4,16,45,100,6.69,16,20,100
+M12-1.75,7.5,19,45,110,7.5,18,50,120,7.79,18,25,120
+M14-2,8.8,22,50,120,8.8,21,60,140,9.09,21,25,140
+M16-2,10,24,50,160,10,24,65,160,10.29,24,30,150
+M18-2.5,11.5,27,65,190,11.5,27,70,180,11.85,27,35,200
+M20-2.5,12.5,30,65,200,12.5,30,80,200,12.85,30,40,160
+M22-2.5,14,32,70,220,14,34,90,220,14.35,34,45,200
+M24-3,15,36,80,240,15,36,90,240,15.35,36,50,180
+M27-3,17,41,90,300,17,41,100,260,17.35,41,50,100
+M30-3.5,18.7,46,90,300,18.7,46,110,300,19.12,46,60,200
+M33-3.5,,,,,21.42,50,130,320,21.42,50,65,200
+M36-4,22.5,55,110,300,22.5,55,140,360,22.95,55,70,200
+M39-4,,,,,25.42,60,150,380,25.42,60,80,200
+M42-4.5,,,,,26,65,160,440,26.42,65,70,200
+M45-4.5,,,,,28.42,70,180,440,28.42,70,90,200
+M48-5,,,,,30,75,190,480,30.42,75,100,200
+M52-5,,,,,33.5,80,200,480,33.5,80,100,200
+M56-5.5,,,,,35,85,220,500,35.5,85,110,200
+M60-5.5,,,,,38.5,90,240,500,38.5,90,120,200
+M64-6,,,,,40,95,260,500,40.5,95,120,200
diff --git a/python/soma/data/fasteners/hex_nut_parameters.csv b/python/soma/data/fasteners/hex_nut_parameters.csv
new file mode 100644
index 0000000..1e33c0f
--- /dev/null
+++ b/python/soma/data/fasteners/hex_nut_parameters.csv
@@ -0,0 +1,32 @@
+Size,iso4032:m,iso4032:s,iso4033:m,iso4033:s,iso4035:m,iso4035:s
+M1.6-0.35,1.3,3.2,,,1,3.2
+M1.8-0.35,,,,,1.1,3.5
+M2-0.4,1.6,4,,,1.2,4
+M2.5-0.45,2,5,,,1.6,5
+M3-0.45,,,,,1.8,5.5
+M3-0.5,2.4,5.5,,,,
+M3.5-0.6,2.8,6,,,2,6
+M4-0.7,3.2,7,,,2.2,7
+M5-0.8,4.7,8,5.1,8,2.7,8
+M6-1,5.2,10,5.7,10,3.2,10
+M8-1.25,6.8,13,7.5,13,4,13
+M10-1.5,8.4,16,9.3,16,5,17
+M12-1.75,10.8,18,12,18,6,19
+M14-2,12.8,21,14.1,21,7,22
+M16-2,14.8,24,16.4,24,8,24
+M18-2.5,15.8,27,,,9,27
+M20-2.5,18,30,20.3,30,10,30
+M22-2.5,19.4,34,,,11,32
+M24-3,21.5,36,23.9,36,12,36
+M27-3,23.8,41,,,13.5,41
+M30-3.5,25.6,46,28.6,46,15,46
+M33-3.5,28.7,50,,,16.5,50
+M36-4,31,55,34.7,55,18,55
+M39-4,33.4,60,,,19.5,60
+M42-4.5,34,65,,,21,65
+M45-4.5,36,70,,,22.5,70
+M48-5,38,75,,,24,75
+M52-5,42,80,,,26,80
+M56-5.5,45,85,,,,
+M60-5.5,48,90,,,,
+M64-6,51,95,,,,
diff --git a/python/soma/data/fasteners/nominal_screw_lengths.csv b/python/soma/data/fasteners/nominal_screw_lengths.csv
new file mode 100644
index 0000000..de545c8
--- /dev/null
+++ b/python/soma/data/fasteners/nominal_screw_lengths.csv
@@ -0,0 +1,31 @@
+Screw_Type,Unit,Nominal_Sizes
+iso7379,mm,"10,12,16,20,25,30,40,50,60,70,80,90,100,120"
+din931,mm,"12,16,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,110,120,130,140,150,160,170,180,190,200,220,240,260,280,300"
+din967,mm,"4,5,6,8,10,12,14,16,20,25,30,35,40,45,50,55,60"
+din968,mm,"4.5,6.5,9.5,13,16,19,22,25,32,38,45,50"
+din1662,mm,"10,12,16,20,25,30,35,40,45,50,55,60,65,70,80,90,100,110,120"
+din1665,mm,"10,12,16,20,25,30,35,40,45,50,55,60,65,70,80,90,100,110,120,130,140,150,160,180,200"
+iso1207,mm,"2,3,4,5,6,8,10,12,14,16,20,25,30,35,40,45,50,55,60,65,70,75,80"
+iso1580,mm,"2,2.5,3,4,5,68,10,12,14,16,20,25,30,35,40,45,50,55,60,65,70,75,80"
+iso2009,mm,"3,4,5,6,8,10,12,14,16,18,20,22,25,28,30,35,40,45,50,55,60,70,80,90,100"
+iso2010,mm,"2,3,4,5,6,8,10,12,14,16,18,20,22,25,30,35,40,45,50,55,60"
+iso4014,mm,"12,16,20,25,30,35,40,45,50,55,60,65,70,80,90,100,110,120,130,140,150,160,180,200,220,240,260,280,300,320,340,360,380,400,420,440,460,480,500"
+iso4017,mm,"2,3,4,5,6,8,10,12,16,20,25,30,35,40,45,50,55,60,65,70,80,90,100,110,120,130,140,150,160,180,200"
+iso4026,mm,"2,2.5,3,3.5,4,5,6,8,10,12,14,16,18,20,22,25,28,30,35,40,45,50,55,60"
+iso4762,mm,"2.5,3,4,5,6,8,10,12,16,20,25,30,35,40,45,50,55,60,65,70,80,90,100,110,120,130,140,150,160,180,200,220,240,260,280,300"
+iso7045,mm,"3,4,5,6,8,10,12,14,16,20,25,30,35,40,45,50,55,60"
+iso7046,mm,"3,4,5,6,8,10,12,14,16,20,25,30,35,40,45,50,55,60"
+iso7047,mm,"3,4,5,6,8,10,12,14,16,20,25,30,35,40,45,50,55,60"
+iso7048,mm,"2,3,4,5,6,8,10,12,16,20,25,30,35,40,45,50,60,70,80"
+iso7380_1,mm,"6,8,10,12,16,20,25,30,35,40,45,50,55,60,65,70,80,90,100"
+iso7380_2,mm,"6,8,10,12,16,20,25,30,35,40,45,50,55,60,65,70,80,90,100"
+iso10642,mm,"8,10,12,16,20,25,30,35,40,50,60,70,80,90,100"
+iso14579,mm,"3,4,5,6,8,10,12,16,20,25,30,35,40,45,50,55,60,65,70,80"
+iso14580,mm,"3,4,5,6,8,10,12,14,16,20,25,30,35,40,45,50,55,60,65,70,75,80"
+iso14581,mm,"3,4,5,6,8,10,12,14,16,20,25,30,35,40,45,50,55,60"
+iso14582,mm,"8,10,12,14,16,20,25,30,35,40,45,50,55,60,65,70,80,90,100"
+iso14583,mm,"3,4,5,6,8,10,12,14,16,20,25,30,35,40,45,50,55,60"
+iso14584,mm,"3,4,5,6,8,10,12,14,16,20,25,30,35,40,45,50,55,60"
+asme_b_18.6.3,in,"0.75,0.88,1.00,1.25,1.50,1.75,2.00,2.25,2.50,2.75,3.00,3.25,3.50,3.75,4.00,4.25,4.50,4.75,5.00,5.25,5.50,5.75,6.00,6.25,6.25,6.50,6.75,7.00,7.25,7.50,7.75,8.00,8.50,9.00,9.50,10.00,11.00,12.00,13.00,14.00,15.00,16.00,17.00,18.00,19.00,20.00"
+asme_b18.3,in,"0.75,0.88,1.00,1.25,1.50,1.75,2.00,2.25,2.50,2.75,3.00,3.25,3.50,3.75,4.00,4.25,4.50,4.75,5.00,5.25,5.50,5.75,6.00,6.25,6.25,6.50,6.75,7.00,7.25,7.50,7.75,8.00,8.50,9.00,9.50,10.00,11.00,12.00,13.00,14.00,15.00,16.00,17.00,18.00,19.00,20.00"
+OpenBuilds,mm,"4,6,8,10,12,15,20,25,27,30,35,40,45,50,55,60,65"
diff --git a/python/soma/data/fasteners/plain_washer_parameters.csv b/python/soma/data/fasteners/plain_washer_parameters.csv
new file mode 100644
index 0000000..55390e9
--- /dev/null
+++ b/python/soma/data/fasteners/plain_washer_parameters.csv
@@ -0,0 +1,34 @@
+Size,iso7089:d1,iso7089:d2,iso7089:h,iso7091:d1,iso7091:d2,iso7091:h,iso7093:d1,iso7093:d2,iso7093:h,iso7094:d1,iso7094:d2,iso7094:h
+M1.6,1.7,4,0.35,1.8,4,0.4,,,,,,
+M1.7,1.8,4.5,0.35,,,,,,,,,
+M2,2.2,5,0.35,2.4,5,0.4,,,,,,
+M2.3,2.5,6,0.55,,,,,,,,,
+M2.5,2.7,6,0.55,2.9,6,0.6,2.7,8,0.9,,,
+M2.6,2.8,7,0.55,,,,,,,,,
+M3,3.2,7,0.55,3.4,7,0.6,3.2,9,0.9,,,
+M3.5,3.7,8,0.55,,,,3.7,11,0.9,,,
+M4,4.3,9,0.9,4.5,9,1,4.3,12,1.1,,,
+M5,5.3,10,1.1,5.5,10,1.2,5.3,15,1.4,5.5,18,2.3
+M6,6.4,12,1.8,6.6,12,1.9,6.4,18,1.8,6.6,22,2.3
+M7,7.4,14,1.8,,,,7.4,22,2.2,,,
+M8,8.4,16,1.8,9,16,1.9,8.4,24,2.2,9,28,3.6
+M10,10.5,20,2.2,11,20,2.3,10.5,30,2.7,11,34,3.6
+M12,13,24,2.7,13.5,24,2.8,13,37,3.3,13.5,44,4.6
+M14,15,28,2.7,,,,15,44,3.3,,,
+M16,17,30,3.3,17.5,30,3.6,17,50,3.3,17.5,56,6
+M18,19,34,3.3,,,,20,56,4.6,,,
+M20,21,37,3.3,22,37,3.6,22,60,4.6,22,72,7
+M22,23,39,3.3,,,,,,,,,
+M24,25,44,4.3,26,44,4.6,26,72,6,26,85,7
+M26,27,50,4.3,,,,,,,,,
+M27,28,50,4.3,,,,,,,,,
+M28,29,50,4.3,,,,,,,,,
+M30,31,56,4.3,33,56,4.6,33,92,7,33,105,7
+M32,33,60,5.6,,,,,,,,,
+M33,34,60,5.6,,,,,,,,,
+M35,36,66,5.6,,,,,,,,,
+M36,37,66,5.6,39,66,6,39,110,9.2,39,125,9.2
+M42,,,,45,78,9.2,,,,,,
+M48,,,,52,92,9.2,,,,,,
+M56,,,,62,105,11.2,,,,,,
+M64,,,,70,115,11.2,,,,,,
diff --git a/python/soma/data/fasteners/setscrew_parameters.csv b/python/soma/data/fasteners/setscrew_parameters.csv
new file mode 100644
index 0000000..1ef6425
--- /dev/null
+++ b/python/soma/data/fasteners/setscrew_parameters.csv
@@ -0,0 +1,16 @@
+Size,iso4026:s,iso4026:t,iso4026:short,iso4026:long
+M1.4-0.3,0.7,1.4,2.5,6
+M1.6-0.35,0.7,1.5,2.5,6
+M1.8-0.35,0.7,1.6,2.5,6
+M2-0.4,0.9,1.7,3,10
+M2.5-0.45,1.3,2,3,10
+M3-0.5,1.5,2,3,20
+M4-0.7,2,2.5,4,20
+M5-0.8,2.5,3,5,25
+M6-1,3,3.5,6,35
+M8-1.25,4,5,8,40
+M10-1.5,5,6,10,40
+M12-1.75,6,8,16,40
+M16-2,8,10,20,40
+M20-2.5,10,12,20,50
+M24-3,12,15,25,60
diff --git a/python/soma/data/fasteners/socket_head_cap_parameters.csv b/python/soma/data/fasteners/socket_head_cap_parameters.csv
new file mode 100644
index 0000000..78e3937
--- /dev/null
+++ b/python/soma/data/fasteners/socket_head_cap_parameters.csv
@@ -0,0 +1,58 @@
+Size,iso4762:dk ,iso4762:k ,iso4762:s ,iso4762:t ,iso4762:short,iso4762:long,asme_b18.3:dk ,asme_b18.3:k ,asme_b18.3:s ,asme_b18.3:t ,asme_b18.3:short,asme_b18.3:long
+M1.6-0.35,3.14,1.6,1.5,0.7,2.5,16,,,,,,
+M2-0.4,3.98,2,1.5,1,3,20,,,,,,
+M2.5-0.45,4.68,2.5,2,1.1,4,25,,,,,,
+M3-0.5,5.68,3,2.5,1.3,5,30,,,,,,
+M4-0.7,7.22,4,3,2,6,40,,,,,,
+M5-0.8,8.72,5,4,2.5,8,50,,,,,,
+M6-1,10.22,6,5,3,8,60,,,,,,
+M8-1.25,13.27,8,6,4,10,80,,,,,,
+M10-1.5,16.27,10,8,5,16,100,,,,,,
+M12-1.75,18.27,12,10,6,20,120,,,,,,
+M14-2,21.33,14,12,7,25,140,,,,,,
+M16-2,24.33,16,14,8,25,160,,,,,,
+M20-2.5,30.33,20,17,10,16,100,,,,,,
+M24-3,36.39,24,19,12,40,200,,,,,,
+M30-3.5,45.39,30,22,15.5,45,200,,,,,,
+M36-4,54.46,36,27,19,55,200,,,,,,
+M42-4.5,63.46,42,32,24,60,300,,,,,,
+M48-5,72.46,48,36,28,100,300,,,,,,
+M56-5.5,84.54,56,41,34,110,300,,,,,,
+M64-6,96.54,64,46,38,120,300,,,,,,
+#0-80,,,,,,,0.096,0.0600,0.050,0.025,0.75,1.25
+#1-64,,,,,,,0.118,0.0730,1/16,0.031,0.88,1.50
+#1-72,,,,,,,0.118,0.0730,1/16,0.031,0.88,1.50
+#2-56,,,,,,,0.140,0.0860,5/64,0.038,0.88,1.75
+#2-64,,,,,,,0.140,0.0860,5/64,0.038,0.88,1.75
+#3-48,,,,,,,0.161,0.0990,5/64,0.044,0.88,2.00
+#3-56,,,,,,,0.161,0.0990,5/64,0.044,0.88,2.00
+#4-36,,,,,,,0.183,0.1120,3/32,0.051,1.00,2.25
+#4-40,,,,,,,0.183,0.1120,3/32,0.051,1.00,2.25
+#4-48,,,,,,,0.183,0.1120,3/32,0.051,1.00,2.25
+#5-40,,,,,,,0.205,0.1250,3/32,0.057,1.00,2.50
+#5-44,,,,,,,0.205,0.1250,3/32,0.057,1.00,2.50
+#6-32,,,,,,,0.226,0.1380,7/64,0.064,1.25,2.75
+#6-40,,,,,,,0.226,0.1380,7/64,0.064,1.25,2.75
+#8-32,,,,,,,0.270,0.1640,9/64,0.077,1.25,3.25
+#8-36,,,,,,,0.270,0.1640,9/64,0.077,1.25,3.25
+#10-24,,,,,,,0.312,0.1900,5/32,0.090,1.25,4.00
+#10-32,,,,,,,0.312,0.1900,5/32,0.090,1.25,4.00
+1/4-20,,,,,,,0.375,0.2500,3/16,0.120,1.50,5.00
+1/4-28,,,,,,,0.375,0.2500,3/16,0.120,1.50,5.00
+5/16-18,,,,,,,0.469,0.3125,1/4,0.151,1.75,6.25
+5/16-24,,,,,,,0.469,0.3125,1/4,0.151,1.75,6.25
+3/8-16,,,,,,,0.562,0.3750,5/16,0.182,1.75,7.50
+3/8-24,,,,,,,0.562,0.3750,5/16,0.182,1.75,7.50
+7/16-14,,,,,,,0.656,0.4375,3/8,0.213,2.00,9.00
+7/16-20,,,,,,,0.656,0.4375,3/8,0.213,2.00,9.00
+1/2-13,,,,,,,0.750,0.5000,3/8,0.245,2.25,10.00
+1/2-20,,,,,,,0.750,0.5000,3/8,0.245,2.25,10.00
+5/8-11,,,,,,,0.938,0.6250,1/2,0.307,2.50,12.00
+5/8-18,,,,,,,0.938,0.6250,1/2,0.307,2.50,12.00
+3/4-10,,,,,,,1.125,0.7500,5/8,0.370,3.00,15.00
+3/4-16,,,,,,,1.125,0.7500,5/8,0.370,3.00,15.00
+7/8-14,,,,,,,1.312,0.8750,3/4,0.432,3.25,18.00
+7/8-9,,,,,,,1.312,0.8750,3/4,0.432,3.25,18.00
+1-8,,,,,,,1.500,1.0000,3/4,0.495,3.50,20.00
+1-12,,,,,,,1.500,1.0000,3/4,0.495,3.50,20.00
+1-14,,,,,,,1.500,1.0000,3/4,0.495,3.50,20.00
\ No newline at end of file
diff --git a/python/soma/data/fasteners/square_nut_parameters.csv b/python/soma/data/fasteners/square_nut_parameters.csv
new file mode 100644
index 0000000..d46910d
--- /dev/null
+++ b/python/soma/data/fasteners/square_nut_parameters.csv
@@ -0,0 +1,7 @@
+Size,din557:m,din557:s
+M5-0.8,4,8
+M6-1,5,10
+M8-1.25,6.5,13
+M10-1.5,8,17
+M12-1.75,10,19
+M16-2,13,24
diff --git a/python/soma/data/fasteners/tap_hole_sizes.csv b/python/soma/data/fasteners/tap_hole_sizes.csv
new file mode 100644
index 0000000..f46dbf9
--- /dev/null
+++ b/python/soma/data/fasteners/tap_hole_sizes.csv
@@ -0,0 +1,100 @@
+Size,Soft,Hard
+M1.5-0.35,1.15,1.25
+M1.6-0.35,1.25,1.35
+M1.8-0.35,1.45,1.55
+M2-0.45,1.55,1.7
+M2-0.4,1.6,1.75
+M2.2-0.45,1.75,1.9
+M2.5-0.45,2.05,2.2
+M3-0.6,2.4,2.6
+M3-0.5,2.5,2.7
+M3.5-0.6,2.9,3.1
+M4-0.75,3.25,3.5
+M4-0.7,3.3,3.5
+M4.5-0.75,3.75,4
+M5-1,4,4.4
+M5-0.9,4.1,4.4
+M5-0.8,4.2,4.5
+M5.5-0.9,4.6,4.9
+M6-1,5,5.4
+M6-0.75,5.25,5.5
+M7-1.0,6,6.4
+M7-0.75,6.25,6.5
+M8-1.25,6.8,7.2
+M8-1,7,7.4
+M9-1.25,7.8,8.2
+M9-1,8,8.4
+M10-1.5,8.5,9
+M10-1.25,8.8,9.2
+M10-1,9,9.4
+M11-1.5,9.5,10
+M12-1.75,10.3,10.9
+M12-1.5,10.5,11
+M12-1.25,10.8,11.2
+M14-2,12.1,12.7
+M14-1.5,12.5,13
+M14-1.25,12.8,13.2
+M15-1.5,13.5,14
+M16-2,14,14.75
+M16-1.5,14.5,15
+M17-1.5,15.5,16
+M18-2.5,15.5,16.5
+M18-2,16,16.75
+M18-1.5,16.5,17
+M19-2.5,16.5,17.5
+M20-2.5,17.5,18.5
+M21-2,18,18.5
+M22-2.5,18.5,19
+#0-80,3/64,#55
+#1-64,#53,1/16
+#1-72,#53,#52
+#2-56,#50,#49
+#2-64,#50,#48
+#3-48,#47,#44
+#3-56,#45,#43
+#4-40,#43,#41
+#4-48,#42,#40
+#5-40,#38,7/64
+#5-44,#37,#35
+#6-32,#36,#32
+#6-40,#33,#31
+#8-32,#29,#27
+#8-36,#29,#26
+#10-24,#25,#20
+#10-32,#21,#18
+#12-24,#16,#12
+#12-28,#14,#10
+#12-32,#13,#9
+1/4-20,#7,7/32
+1/4-28,#3,#1
+1/4-32,7/32,#1
+5/16-18,F,J
+5/16-24,I,9/32
+5/16-32,9/32,L
+3/8-16,5/16,Q
+3/8-24,Q,S
+3/8-32,11/32,T
+7/16-14,U,25/64
+7/16-20,25/64,13/32
+7/16-28,Y,Z
+1/2-13,27/64,29/64
+1/2-20,29/64,15/32
+1/2-28,15/32,15/32
+9/16-12,31/64,33/64
+9/16-18,33/64,17/32
+9/16-24,33/64,17/32
+5/8-11,17/32,9/16
+5/8-18,37/64,19/32
+5/8-24,37/64,19/32
+11/16-24,41/64,21/32
+3/4-10,21/32,11/16
+3/4-16,11/16,45/64
+3/4-20,45/64,23/32
+13/16-20,49/64,25/32
+7/8-9,49/64,51/64
+7/8-14,13/16,53/64
+7/8-20,53/64,27/32
+15/16-20,57/64,29/32
+1-8,7/8,59/64
+1-12,15/16,61/64
+1-20,61/64,31/32
diff --git a/python/soma/fasteners.py b/python/soma/fasteners.py
new file mode 100644
index 0000000..4b617bb
--- /dev/null
+++ b/python/soma/fasteners.py
@@ -0,0 +1,804 @@
+"""Normteile: Schrauben, Muttern, Scheiben und Gewindeeinsaetze, vereinfacht ohne Gewinde, mit passenden Bohrungen.
+
+ from soma import add_part
+ from soma.fasteners import Screw
+
+ s = Screw("ISO 4762", "M3x10", at=(20, 15, 8)) # Kopf liegt bei z = 8 auf, der Schaft zeigt nach unten
+ lid = lid.cut(s.clearance_hole()) # Durchgangsloch, bei versenktem Kopf mit Senkung
+ add_part("Schraube 1", s) # Rolle "hardware" (Zukaufteil), nicht in export --all
+
+Lage, fuer alle Teile gleich: `at` ist der Punkt auf der Achse, an dem das Teil aufliegt. `direction` zeigt von dort
+ins Material (Standard "-Z": von oben nach unten). Eine Schraube liegt mit der Kopfunterseite auf, eine Mutter oder
+Scheibe mit einer Stirnseite. Senkschraube, Gewindestift und Gewindeeinsatz schliessen mit ihrer Oberseite an `at` ab.
+`sunk=True` versenkt Kopf, Mutter oder Scheibe buendig (die Aussenseite liegt dann an `at`), `sunk=0.5` 0,5 mm tiefer.
+`on=teil` sucht die Auflage selbst: Die Gerade durch `at` in Richtung `direction` trifft das Teil, der erste Treffer
+gilt (bei "-Z" zaehlen dann nur x und y von `at`).
+
+Die Masse stammen aus den Tabellen von bd_warehouse (Apache 2.0, siehe data/fasteners/QUELLE.md), teils Nenn-, teils
+Groesstmasse. Gewinde werden nicht modelliert: Schaft und Bohrung der Mutter haben den Nenndurchmesser.
+"""
+import csv
+import functools
+import math
+import numbers
+import re
+from pathlib import Path
+
+import cadquery as cq
+from OCP.BRepIntCurveSurface import BRepIntCurveSurface_Inter
+from OCP.gp import gp_Dir, gp_Lin, gp_Pnt
+
+__all__ = ["Screw", "Nut", "Washer", "HeatSetInsert", "lengths", "pick_length", "standards"]
+
+_DATA = Path(__file__).parent / "data" / "fasteners"
+INCH = 25.4
+# Bohrwerkzeuge ragen so weit ueber die Oberflaeche hinaus: Deckungsgleiche Flaechen machen cut() unzuverlaessig
+MARGIN = 1.0
+# Durchgangsloecher nach ISO 273, wie im Skill "Toleranzen" benannt, mit den Spalten der Tabelle
+FITS = {"fine": "Close", "medium": "Normal", "coarse": "Loose"}
+STEEL = (0.45, 0.46, 0.49)
+BRASS = (0.80, 0.63, 0.32)
+COS30 = math.cos(math.radians(30))
+
+# Regelgewinde nach ISO 261. Manche Tabellen fuehren dasselbe Mass mit mehreren Steigungen, ohne Gewinde zaehlt nur
+# der Durchmesser, die Steigung waehlt bei Kernloechern die richtige Zeile.
+COARSE_PITCH = {
+ 1: 0.25, 1.2: 0.25, 1.4: 0.3, 1.6: 0.35, 1.8: 0.35, 2: 0.4, 2.5: 0.45, 3: 0.5, 3.5: 0.6, 4: 0.7, 5: 0.8, 6: 1.0,
+ 7: 1.0, 8: 1.25, 10: 1.5, 12: 1.75, 14: 2.0, 16: 2.0, 18: 2.5, 20: 2.5, 22: 2.5, 24: 3.0, 27: 3.0, 30: 3.5, 33: 3.5,
+ 36: 4.0, 39: 4.0, 42: 4.5, 45: 4.5, 48: 5.0, 52: 5.0, 56: 5.5, 60: 5.5, 64: 6.0,
+}
+
+# Kopf: socket (Zylinderkopf), button (Linsenkopf), countersunk (Senkkopf), hex (Sechskant), set (Gewindestift)
+SCREWS = {
+ "iso4762": dict(name="ISO 4762", title="Zylinderschraube mit Innensechskant", table="socket_head_cap_parameters.csv",
+ col="iso4762", head="socket", cols=("dk", "k", "s", "t")),
+ "iso7380": dict(name="ISO 7380", title="Linsenkopfschraube mit Innensechskant", table="button_head_parameters.csv",
+ col="iso7380_1", head="button", cols=("dk", "dl", "k", "rf", "s", "t")),
+ "iso10642": dict(name="ISO 10642", title="Senkschraube mit Innensechskant", table="countersunk_head_parameters.csv",
+ col="iso10642", head="countersunk", cols=("a", "dk", "k", "s", "t")),
+ "iso4017": dict(name="ISO 4017", title="Sechskantschraube mit Gewinde bis Kopf", table="hex_head_parameters.csv",
+ col="iso4017", head="hex", cols=("k", "s")),
+ "iso4014": dict(name="ISO 4014", title="Sechskantschraube mit Schaft", table="hex_head_parameters.csv",
+ col="iso4014", head="hex", cols=("k", "s")),
+ "din931": dict(name="DIN 931", title="Sechskantschraube mit Schaft", table="hex_head_parameters.csv",
+ col="din931", head="hex", cols=("k", "s")),
+ "iso4026": dict(name="ISO 4026", title="Gewindestift mit Innensechskant und Kegelstumpf", table="setscrew_parameters.csv",
+ col="iso4026", head="set", cols=("s", "t")),
+}
+NUTS = {
+ "iso4032": dict(name="ISO 4032", title="Sechskantmutter", table="hex_nut_parameters.csv", col="iso4032", shape="hex"),
+ "iso4033": dict(name="ISO 4033", title="Sechskantmutter, hoch", table="hex_nut_parameters.csv", col="iso4033", shape="hex"),
+ "iso4035": dict(name="ISO 4035", title="Sechskantmutter, flach", table="hex_nut_parameters.csv", col="iso4035", shape="hex"),
+ "din557": dict(name="DIN 557", title="Vierkantmutter", table="square_nut_parameters.csv", col="din557", shape="square"),
+}
+WASHERS = {
+ "iso7089": dict(name="ISO 7089", title="Scheibe", table="plain_washer_parameters.csv", col="iso7089"),
+ "iso7091": dict(name="ISO 7091", title="Scheibe, grob", table="plain_washer_parameters.csv", col="iso7091"),
+ "iso7093": dict(name="ISO 7093", title="Scheibe, gross", table="plain_washer_parameters.csv", col="iso7093"),
+}
+INSERT_BRANDS = {"ruthex": "ruthex", "cnckitchen": "CNCKitchen", "mcmaster": "McMaster-Carr", "mcmastercarr": "McMaster-Carr",
+ "hilitchi": "Hilitchi", "aesamzhihui": "AE-SamZhihui"}
+ALIASES = {"iso73801": "iso7380"}
+# Alte DIN-Bezeichnungen: melden statt still umdeuten, weil manche Masse abweichen
+HINTS = {
+ "din912": "ISO 4762", "din7380": "ISO 7380", "din7991": "ISO 10642 (Kopfhoehe weicht etwas ab)",
+ "din933": "ISO 4017 (bei M10, M12, M14 und M22 andere Schluesselweite als DIN 933)", "din913": "ISO 4026 (Ende anders)",
+ "din916": "ISO 4026 (Ende anders)", "din934": "ISO 4032 (bei M10, M12, M14 und M22 andere Schluesselweite als DIN 934)",
+ "din439": "ISO 4035", "din125": "ISO 7089", "din9021": "ISO 7093",
+}
+
+
+# --- Tabellen ----------------------------------------------------------------------------------------------------------
+
+def _table(name):
+ """CSV als Liste von (Schluessel, {Spalte: Wert}). Kopfzeilen haben teils Leerzeichen am Rand, die fallen weg."""
+ with open(_DATA / name, encoding="utf-8-sig", newline="") as f:
+ rows = list(csv.reader(f))
+ head = [h.strip() for h in rows[0]]
+ return [(r[0].strip(), {h: v.strip() for h, v in zip(head[1:], r[1:])}) for r in rows[1:] if r and r[0].strip()]
+
+
+_KEY = re.compile(r"^M(\d+(?:\.\d+)?)(?:-(\d+(?:\.\d+)?))?(?:-(.*))?$")
+
+
+def _key(key):
+ """"M3-0.5" -> (3.0, 0.5, ""), "M3-0.5-5.7" -> (3.0, 0.5, "5.7"), "M3" -> (3.0, None, ""). Zoll-Zeilen: None."""
+ m = _KEY.match(key)
+ if not m:
+ return None, None, ""
+ return float(m.group(1)), float(m.group(2)) if m.group(2) else None, m.group(3) or ""
+
+
+def _num(text):
+ return float(text.replace(",", "."))
+
+
+def _rows(table, col, cols):
+ """Alle metrischen Zeilen mit Werten fuer jede Spalte in `cols`: [(d, steigung, rest, {spalte: zahl})]."""
+ out = []
+ for key, row in _table(table):
+ d, pitch, rest = _key(key)
+ if d is None:
+ continue
+ vals = {c: row.get(f"{col}:{c}", "") if col else row.get(c, "") for c in cols}
+ if all(vals.values()):
+ try:
+ out.append((d, pitch, rest, {c: v if c in ("drill", "part") else _num(v) for c, v in vals.items()}))
+ except ValueError:
+ continue
+ return out
+
+
+def _lookup(table, col, cols, d, what):
+ """Werte fuer M<d>. Bevorzugt die Zeile mit Regelgewinde, sonst die erste Zeile mit Werten."""
+ rows = [r for r in _rows(table, col, cols) if abs(r[0] - d) < 1e-9]
+ if not rows:
+ sizes = sorted({r[0] for r in _rows(table, col, cols)})
+ raise ValueError(f"{what}: Groesse M{_fmt(d)} gibt es in der Tabelle nicht. Vorhanden: "
+ + ", ".join(f"M{_fmt(x)}" for x in sizes))
+ coarse = [r for r in rows if r[1] is None or abs(r[1] - COARSE_PITCH.get(d, -1)) < 1e-9]
+ return (coarse or rows)[0][3]
+
+
+def _fmt(x):
+ """3.0 -> "3", 2.5 -> "2.5": Zahlen so, wie man sie in Bezeichnungen schreibt."""
+ return f"{x:g}"
+
+
+def _norm_standard(standard, table, kind):
+ if not isinstance(standard, str) or not standard.strip():
+ raise ValueError(f"{kind}: Norm als Text angeben, z. B. {next(iter(table.values()))['name']!r}")
+ key = re.sub(r"[\s_.-]", "", standard.lower())
+ key = ALIASES.get(key, key)
+ if key in table:
+ return key
+ known = ", ".join(v["name"] for v in table.values())
+ if key in HINTS:
+ raise ValueError(f"{kind}: {standard!r} heisst heute {HINTS[key]}. Moeglich: {known}")
+ raise ValueError(f"{kind}: Norm {standard!r} gibt es hier nicht. Moeglich: {known}")
+
+
+_SIZE = re.compile(r"^\s*M\s*(\d+(?:[.,]\d+)?)\s*(?:[xX×*]\s*(\d+(?:[.,]\d+)?)\s*(?:mm)?)?\s*$", re.IGNORECASE)
+
+
+def _parse_size(size, length, kind):
+ """"M3" oder "M3x10" (auch "M3 x 10", "M3×10") -> (3.0, Laenge oder None)."""
+ if not isinstance(size, str):
+ raise ValueError(f"{kind}: Groesse als Text angeben, z. B. \"M3\" oder \"M3x10\", nicht {size!r}")
+ m = _SIZE.match(size)
+ if not m:
+ raise ValueError(f"{kind}: Groesse {size!r} nicht lesbar. Erwartet z. B. \"M3\" oder \"M3x10\"")
+ d = _num(m.group(1))
+ if m.group(2):
+ from_size = _num(m.group(2))
+ if length is not None and abs(float(length) - from_size) > 1e-9:
+ raise ValueError(f"{kind}: Laenge doppelt und verschieden angegeben ({size!r} und length={length})")
+ length = from_size
+ return d, (float(length) if length is not None else None)
+
+
+def _split_designation(standard, size):
+ """"ISO 4762 M3x10" als ein Text -> ("ISO 4762", "M3x10")."""
+ if size is None and isinstance(standard, str):
+ m = re.match(r"^\s*(.*?)\s+(M\s*\d.*)$", standard, re.IGNORECASE)
+ if m:
+ return m.group(1), m.group(2)
+ return standard, size
+
+
+def _nominal_lengths():
+ out = {}
+ with open(_DATA / "nominal_screw_lengths.csv", encoding="utf-8-sig", newline="") as f:
+ for row in csv.DictReader(f):
+ if row["Unit"].strip() == "mm":
+ out[row["Screw_Type"].strip()] = [_num(x) for x in row["Nominal_Sizes"].split(",") if x.strip()]
+ return out
+
+
+def _length_range(spec, d):
+ """Kleinste und groesste Laenge der Tabelle fuer diese Groesse."""
+ vals = _lookup(spec["table"], spec["col"], ("short", "long"), d, spec["name"])
+ return vals["short"], vals["long"]
+
+
+def lengths(standard, size):
+ """Normlaengen einer Schraube in mm, z. B. lengths("ISO 4762", "M3") -> [5, 6, 8, 10, 12, 16, 20, 25, 30]."""
+ key = _norm_standard(standard, SCREWS, "Schraube")
+ spec = SCREWS[key]
+ d, _ = _parse_size(size, None, spec["name"])
+ short, long_ = _length_range(spec, d)
+ series = _nominal_lengths().get(spec["col"], [])
+ return [x for x in series if short - 1e-9 <= x <= long_ + 1e-9]
+
+
+def pick_length(standard, size, min_length, max_length=None):
+ """Kuerzeste Normlaenge, die mindestens `min_length` lang ist (und hoechstens `max_length`, wenn angegeben)."""
+ options = lengths(standard, size)
+ fitting = [x for x in options if x >= min_length - 1e-9 and (max_length is None or x <= max_length + 1e-9)]
+ if not fitting:
+ span = f"{_fmt(min_length)} bis {_fmt(max_length)}" if max_length is not None else f"mindestens {_fmt(min_length)}"
+ raise ValueError(f"{standard} {size}: keine Normlaenge {span} mm. Normlaengen: "
+ + ", ".join(_fmt(x) for x in options))
+ return fitting[0]
+
+
+def standards():
+ """Was es gibt: {"Schrauben": {"ISO 4762": "Zylinderschraube ..."}, ...}."""
+ return {
+ "Schrauben": {v["name"]: v["title"] for v in SCREWS.values()},
+ "Muttern": {v["name"]: v["title"] for v in NUTS.values()},
+ "Scheiben": {v["name"]: v["title"] for v in WASHERS.values()},
+ "Gewindeeinsaetze": sorted(set(INSERT_BRANDS.values())),
+ }
+
+
+def _clearance(d, fit):
+ if fit not in FITS:
+ raise ValueError(f"fit muss einer von {tuple(FITS)} sein (ISO 273 fein, mittel, grob), nicht {fit!r}")
+ rows = [r for r in _rows("clearance_hole_sizes.csv", None, (FITS[fit],)) if abs(r[0] - d) < 1e-9]
+ if not rows:
+ raise ValueError(f"Fuer M{_fmt(d)} gibt es kein Durchgangsloch in der Tabelle")
+ return rows[0][3][FITS[fit]]
+
+
+def _tap_drill(d):
+ return _lookup("tap_hole_sizes.csv", None, ("Soft",), d, "Kernloch")["Soft"]
+
+
+def _drills():
+ with open(_DATA / "drill_sizes.csv", encoding="utf-8-sig", newline="") as f:
+ return {r[0].strip(): _num(r[1].strip()) * INCH for r in list(csv.reader(f))[1:] if len(r) > 1}
+
+
+def _drill_mm(code):
+ """Bohrergroesse der Tabelle in mm: Nummern ("#21") und Buchstaben ("F") sind Zollbohrer. Anderes (die Tabelle
+ nennt bei M10 "M14", groesser als der Einsatz) gilt als unbekannt."""
+ return _drills().get(code.strip())
+
+
+# --- Lage --------------------------------------------------------------------------------------------------------------
+
+def _vec(v, what):
+ if isinstance(v, cq.Vector):
+ return v
+ if isinstance(v, cq.Vertex):
+ return cq.Vector(*v.toTuple())
+ if isinstance(v, (tuple, list)) and len(v) == 3 and all(isinstance(x, numbers.Real) for x in v):
+ return cq.Vector(*map(float, v))
+ raise ValueError(f"{what}: erwartet (x, y, z), nicht {v!r}")
+
+
+def _direction(spec):
+ if isinstance(spec, str):
+ m = re.match(r"^\s*([+-]?)\s*([xyz])\s*$", spec, re.IGNORECASE)
+ if not m:
+ raise ValueError(f"direction: erwartet \"-Z\", \"+X\" usw. oder (x, y, z), nicht {spec!r}")
+ v = cq.Vector(*[(-1.0 if m.group(1) == "-" else 1.0) if a == m.group(2).lower() else 0.0 for a in "xyz"])
+ else:
+ v = _vec(spec, "direction")
+ if v.Length < 1e-9:
+ raise ValueError("direction darf nicht (0, 0, 0) sein")
+ return v.normalized()
+
+
+def _at(at, on):
+ """Punkt und (falls ableitbar) Richtung aus `at`: Tupel, Vector, Vertex, Location oder Workplane."""
+ if at is None:
+ raise ValueError("at fehlt: der Punkt, an dem das Teil aufliegt, z. B. at=(10, 5, 8)")
+ if isinstance(at, cq.Location):
+ pos = cq.Vector(*at.toTuple()[0])
+ z = gp_Dir(0, 0, 1).Transformed(at.wrapped.Transformation())
+ return pos, -cq.Vector(z.X(), z.Y(), z.Z())
+ if isinstance(at, cq.Workplane):
+ objs = at.objects
+ if not objs: # Workplane auf einer Flaeche: Ursprung der Ebene, ins Material gegen die Normale
+ return at.plane.origin, -at.plane.zDir
+ if len(objs) == 1:
+ return _at(objs[0], on)[0], -at.plane.zDir
+ raise ValueError(f"at: die Workplane traegt {len(objs)} Punkte. Je Teil einen Punkt uebergeben (Schleife ueber .vals())")
+ if isinstance(at, (tuple, list)) and len(at) == 2:
+ if on is None:
+ raise ValueError("at braucht x, y und z. Nur (x, y) geht mit on=teil, dann wird die Auflage gesucht")
+ return cq.Vector(float(at[0]), float(at[1]), 0.0), None
+ return _vec(at, "at"), None
+
+
+def _shape_of(obj, what="on"):
+ if hasattr(obj, "__soma_shape__"):
+ return obj.__soma_shape__()
+ if isinstance(obj, cq.Workplane):
+ vals = [v for v in obj.vals() if isinstance(v, cq.Shape)]
+ if not vals:
+ raise ValueError(f"{what}: die Workplane enthaelt keine Geometrie")
+ return vals[0] if len(vals) == 1 else cq.Compound.makeCompound(vals)
+ if isinstance(obj, cq.Assembly):
+ return obj.toCompound()
+ if isinstance(obj, cq.Shape):
+ return obj
+ raise ValueError(f"{what}: erwartet ein Teil (cq.Workplane oder cq.Shape), nicht {type(obj).__name__}")
+
+
+def _surface_hit(on, point, d):
+ """Erster Schnittpunkt der Geraden durch `point` in Richtung `d` mit `on`, von aussen her gesehen."""
+ shape = _shape_of(on)
+ inter = BRepIntCurveSurface_Inter()
+ inter.Init(shape.wrapped, gp_Lin(gp_Pnt(*point.toTuple()), gp_Dir(*d.toTuple())), 1e-7)
+ best = None
+ while inter.More():
+ if best is None or inter.W() < best[0]:
+ p = inter.Pnt()
+ best = (inter.W(), cq.Vector(p.X(), p.Y(), p.Z()))
+ inter.Next()
+ if best is None:
+ raise ValueError(f"on: die Gerade durch {_pt(point)} in Richtung {_pt(d)} trifft das Teil nicht. "
+ "Pruefe at und direction")
+ return best[1]
+
+
+def _pt(v):
+ return "(" + ", ".join(_fmt(round(c, 4)) for c in v.toTuple()) + ")"
+
+
+def _sink(sunk, kind):
+ """None: nicht versenkt, sonst die Tiefe unter `at` (0 bei sunk=True)."""
+ if sunk is False or sunk is None:
+ return None
+ if sunk is True:
+ return 0.0
+ if isinstance(sunk, numbers.Real) and sunk >= 0:
+ return float(sunk)
+ raise ValueError(f"{kind}: sunk ist True, False oder eine Tiefe in mm (>= 0), nicht {sunk!r}")
+
+
+class _Part:
+ """Gemeinsame Lage. Lokal: Auflage bei z = 0, +Z zeigt aus dem Material, die Oberflaeche (`at`) liegt bei z = _zs."""
+
+ role = "hardware"
+ color = STEEL
+
+ def _place(self, at, direction, on, angle, zs):
+ point, derived = _at(at, on)
+ d = _direction(direction) if direction is not None else (derived.normalized() if derived is not None else _direction("-Z"))
+ if on is not None:
+ point = _surface_hit(on, point, d)
+ if not isinstance(angle, numbers.Real):
+ raise ValueError(f"angle: Drehung um die Achse in Grad, nicht {angle!r}")
+ ref = cq.Vector(1, 0, 0) if abs(d.x) < 0.99 else cq.Vector(0, 1, 0)
+ x = (ref - d * ref.dot(d)).normalized()
+ n = -d # lokale Z-Achse
+ a = math.radians(angle)
+ x = x * math.cos(a) + n.cross(x) * math.sin(a)
+ self._dir, self._zs = d, zs
+ self._surface = point
+ self._plane = cq.Plane(origin=point + d * zs, xDir=x, normal=n)
+ self._loc = cq.Location(self._plane)
+
+ def _world(self, local):
+ return local.moved(self._loc)
+
+ def _local_point(self, z):
+ return (self._plane.origin + self._plane.zDir * z).toTuple()
+
+ @property
+ def direction(self):
+ """Einheitsvektor von der Auflage ins Material."""
+ return self._dir.toTuple()
+
+ @property
+ def seat(self):
+ """Punkt auf der Achse an der Auflage (Kopfunterseite, Stirnseite der Mutter)."""
+ return self._local_point(0.0)
+
+ @property
+ def surface(self):
+ """Punkt auf der Achse an der Oberflaeche, auf der das Teil sitzt (`at`, mit on= der gefundene Punkt)."""
+ return self._surface.toTuple()
+
+ def point(self, distance):
+ """Punkt auf der Achse, `distance` mm von der Auflage ins Material (z. B. fuer die Mutter am anderen Ende)."""
+ return self._local_point(-float(distance))
+
+ @property
+ def shape(self):
+ """Das Teil als cq.Solid an seiner Lage."""
+ return self._world(self._local())
+
+ def __soma_shape__(self):
+ return self.shape
+
+ def __repr__(self):
+ return f"<{self.designation} an {_pt(cq.Vector(*self.seat))}, Richtung {_pt(self._dir)}>"
+
+
+def _cyl(d, z0, z1):
+ """Zylinder entlang Z von z0 bis z1."""
+ lo, hi = min(z0, z1), max(z0, z1)
+ return cq.Solid.makeCylinder(d / 2, hi - lo, cq.Vector(0, 0, lo), cq.Vector(0, 0, 1))
+
+
+def _hex_prism(s, z0, z1):
+ """Sechskant mit Schluesselweite s, zwei Flaechen parallel zur lokalen X-Achse."""
+ return cq.Workplane().workplane(offset=z0).polygon(6, s / COS30).extrude(z1 - z0).val()
+
+
+def _chamfered_hex(s, h, both):
+ """Sechskant mit 30-Grad-Fase an den Ecken (oben, bei Muttern auch unten), wie bei Kopf und Mutter ueblich."""
+ e = s / COS30
+ c = (e - s) / 2 * math.tan(math.radians(30))
+ pts = [(0, 0), (s / 2, 0), (e / 2, c), (e / 2, h - c), (s / 2, h), (0, h)] if both else \
+ [(0, 0), (e / 2, 0), (e / 2, h - c), (s / 2, h), (0, h)]
+ body = cq.Workplane("XZ").polyline(pts).close().revolve(360, (0, 0, 0), (0, 1, 0)).val()
+ return _hex_prism(s, 0, h).intersect(body)
+
+
+def _socket(solid, s, t, z_top):
+ """Innensechskant mit Schluesselweite s und Tiefe t von der Oberseite z_top aus."""
+ return solid.cut(_hex_prism(s, z_top - t, z_top + 0.01))
+
+
+def _one(shape):
+ """Boolesche Operationen liefern teils einen Compound mit einem Koerper: dann den Koerper selbst."""
+ shape = shape.clean()
+ solids = shape.Solids()
+ return solids[0] if len(solids) == 1 else shape
+
+
+def _arc_mid(p1, p2, r):
+ """Mittelpunkt des Bogens mit Radius r von p1 nach p2, nach aussen gewoelbt (Linsenkopf)."""
+ (x1, z1), (x2, z2) = p1, p2
+ vx, vz = x2 - x1, z2 - z1
+ c = math.hypot(vx, vz)
+ h = math.sqrt(max(r * r - c * c / 4, 0.0))
+ nx, nz = -vz / c, vx / c # Normale zur Achse hin und nach unten
+ if nx > 0:
+ nx, nz = -nx, -nz
+ mx, mz = (x1 + x2) / 2, (z1 + z2) / 2
+ return mx - (r - h) * nx, mz - (r - h) * nz
+
+
+# --- Schrauben ---------------------------------------------------------------------------------------------------------
+
+def _screw_local(head, d, length, pitch, dims):
+ p = dict(dims)
+ tip = min(0.6 * pitch, 0.2 * d)
+ if head == "set": # ganz im Material: Oberseite bei z = 0, Kegelstumpf an beiden Enden
+ body = cq.Workplane().circle(d / 2).extrude(-length).faces("<Z or >Z").chamfer(tip).val()
+ return _one(_socket(body, p["s"], p["t"], 0.0))
+ shank = cq.Workplane().circle(d / 2).extrude(-length).faces("<Z").chamfer(tip).val()
+ if head == "socket":
+ cap = cq.Workplane().circle(p["dk"] / 2).extrude(p["k"]).faces(">Z").chamfer(0.06 * p["dk"]).val()
+ cap = _socket(cap, p["s"], p["t"], p["k"])
+ elif head == "button":
+ mid = _arc_mid((p["dk"] / 2, 0), (p["dl"] / 2, p["k"]), p["rf"])
+ cap = (cq.Workplane("XZ").moveTo(0, 0).lineTo(p["dk"] / 2, 0).threePointArc(mid, (p["dl"] / 2, p["k"]))
+ .lineTo(0, p["k"]).close().revolve(360, (0, 0, 0), (0, 1, 0)).val())
+ cap = _socket(cap, p["s"], p["t"], p["k"])
+ elif head == "countersunk": # Kegel unter der Oberseite, die Laenge zaehlt ab der Oberseite
+ hc = (p["dk"] - d) / 2 / math.tan(math.radians(p["a"] / 2))
+ cap = cq.Solid.makeCone(d / 2, p["dk"] / 2, hc, cq.Vector(0, 0, -hc), cq.Vector(0, 0, 1))
+ cap = _socket(cap, p["s"], p["t"], 0.0)
+ elif head == "hex":
+ cap = _chamfered_hex(p["s"], p["k"], both=False)
+ else:
+ raise ValueError(f"Kopfform {head!r} unbekannt")
+ return _one(cap.fuse(shank))
+
+
+class Screw(_Part):
+ """Schraube ohne Gewinde. Screw("ISO 4762", "M3x10", at=(x, y, z)) oder Screw("ISO 4762", "M3", 10, at=...).
+
+ standard "ISO 4762" (Zylinderkopf), "ISO 7380" (Linsenkopf), "ISO 10642" (Senkkopf), "ISO 4017", "ISO 4014",
+ "DIN 931" (Sechskant), "ISO 4026" (Gewindestift)
+ at Auflage der Kopfunterseite (Senkschraube, Gewindestift: Oberseite), (x, y, z) oder cq.Location
+ direction von der Auflage ins Material, Standard "-Z"
+ on Teil, auf dem die Schraube sitzt: Die Auflage wird entlang `direction` gesucht
+ sunk True: Kopf buendig in einer Senkung, 0.5: 0,5 mm tiefer. Senkschrauben sitzen immer buendig
+ angle Drehung um die Achse in Grad (Lage des Sechskants)
+ check_length False erlaubt Laengen, die keine Normlaenge sind
+ """
+
+ def __init__(self, standard, size=None, length=None, *, at=None, direction=None, on=None, sunk=False, angle=0.0,
+ check_length=True):
+ standard, size = _split_designation(standard, size)
+ self.standard_key = _norm_standard(standard, SCREWS, "Schraube")
+ spec = SCREWS[self.standard_key]
+ self.standard = spec["name"]
+ self.d, length = _parse_size(size, length, spec["name"])
+ if length is None:
+ raise ValueError(f"{spec['name']} M{_fmt(self.d)}: Laenge fehlt, z. B. \"M{_fmt(self.d)}x10\". "
+ f"Normlaengen: {', '.join(_fmt(x) for x in lengths(standard, size))}")
+ if length <= 0:
+ raise ValueError(f"{spec['name']}: Laenge muss groesser als 0 sein")
+ self.dims = _lookup(spec["table"], spec["col"], spec["cols"], self.d, spec["name"])
+ self.length = length
+ self.head = spec["head"]
+ self.pitch = COARSE_PITCH.get(self.d, 0.1 * self.d)
+ if check_length:
+ options = lengths(standard, f"M{_fmt(self.d)}")
+ if options and not any(abs(length - x) < 1e-9 for x in options):
+ raise ValueError(f"{self.designation}: {_fmt(length)} mm ist keine Normlaenge. Normlaengen: "
+ f"{', '.join(_fmt(x) for x in options)}. Sonderlaenge: check_length=False")
+ if self.head == "set" and length < self.dims["t"]:
+ raise ValueError(f"{self.designation}: kuerzer als der Innensechskant tief ist ({_fmt(self.dims['t'])} mm)")
+ sink = _sink(sunk, spec["name"])
+ self.sunk = sink is not None
+ if self.head in ("countersunk", "set"): # sitzen ohnehin im Material, `sunk` legt sie nur tiefer
+ zs = sink or 0.0
+ else:
+ zs = self.head_height + sink if sink is not None else 0.0
+ self._place(at, direction, on, angle, zs)
+
+ @property
+ def designation(self):
+ return f"{self.standard} M{_fmt(self.d)}x{_fmt(self.length)}"
+
+ @property
+ def head_diameter(self):
+ """Kopfdurchmesser, beim Sechskant das Eckmass."""
+ if self.head == "hex":
+ return self.dims["s"] / COS30
+ return self.dims["dk"] if "dk" in self.dims else self.d
+
+ @property
+ def head_height(self):
+ if self.head == "countersunk":
+ return (self.dims["dk"] - self.d) / 2 / math.tan(math.radians(self.dims["a"] / 2))
+ return self.dims.get("k", 0.0)
+
+ @property
+ def key(self):
+ """Schluesselweite: Innensechskant oder Sechskant aussen."""
+ return self.dims["s"]
+
+ @property
+ def tip(self):
+ """Punkt auf der Achse am Ende des Schafts."""
+ return self.point(self.length)
+
+ @property
+ def outer(self):
+ """Punkt auf der Achse an der Kopfoberseite."""
+ return self._local_point(0.0 if self.head in ("countersunk", "set") else self.head_height)
+
+ @property
+ def lengths(self):
+ return lengths(self.standard, f"M{_fmt(self.d)}")
+
+ def clearance(self, fit="medium"):
+ """Durchmesser des Durchgangslochs nach ISO 273: fit "fine", "medium" oder "coarse"."""
+ return _clearance(self.d, fit)
+
+ @property
+ def tap_drill(self):
+ """Kernlochdurchmesser fuer das Regelgewinde."""
+ return _tap_drill(self.d)
+
+ def _local(self):
+ return _screw_local(self.head, self.d, self.length, self.pitch, tuple(sorted(self.dims.items())))
+
+ def clearance_hole(self, fit="medium", depth=None, oversize=0.0, recess=None):
+ """Werkzeug fuer cut(): Durchgangsloch, bei versenktem Kopf mit Senkung, bei Senkschrauben mit 90-Grad-Kegel.
+
+ fit ISO 273: "fine", "medium" (Standard) oder "coarse"
+ depth Tiefe ab der Oberflaeche (`at`), Standard: bis 1 mm hinter das Schaftende
+ oversize zusaetzlich auf alle Durchmesser (3D-Druck: Loecher kommen kleiner heraus)
+ recess Durchmesser der Senkung statt Kopf + Spiel (z. B. Platz fuer einen Steckschluessel)
+ """
+ c0 = self.clearance(fit)
+ c = c0 + oversize
+ top = self._zs + MARGIN
+ bottom = self._zs - depth if depth is not None else -(self.length + 1.0)
+ tool = _cyl(c, bottom, top)
+ gap = c0 - self.d + oversize # Spiel am Kopf wie am Schaft
+ if self.head == "countersunk":
+ big = recess or self.dims["dk"] + gap
+ h = (big - c) / 2 / math.tan(math.radians(self.dims["a"] / 2))
+ cone = cq.Solid.makeCone(c / 2, big / 2, h, cq.Vector(0, 0, -h), cq.Vector(0, 0, 1))
+ tool = tool.fuse(cone, _cyl(big, 0.0, top))
+ elif self.sunk and self.head != "set":
+ tool = tool.fuse(_cyl(recess or self.head_diameter + gap, 0.0, top))
+ return self._world(_one(tool))
+
+ def tap_hole(self, depth=None, diameter=None, oversize=0.0):
+ """Werkzeug fuer cut(): Kernloch fuer ein Gewinde (oder zum Eindrehen in Kunststoff mit eigenem `diameter`).
+ depth: Tiefe ab der Oberflaeche, Standard bis 3 Steigungen hinter das Schaftende."""
+ dia = (diameter or self.tap_drill) + oversize
+ bottom = self._zs - depth if depth is not None else -(self.length + 3 * self.pitch)
+ return self._world(_cyl(dia, bottom, self._zs + MARGIN))
+
+
+# --- Muttern, Scheiben, Gewindeeinsaetze -------------------------------------------------------------------------------
+
+def _nut_local(shape, d, m, s):
+ if shape == "hex":
+ body = _chamfered_hex(s, m, both=True)
+ else:
+ body = cq.Solid.makeBox(s, s, m, cq.Vector(-s / 2, -s / 2, 0))
+ return _one(body.cut(_cyl(d, -0.01, m + 0.01)))
+
+
+class Nut(_Part):
+ """Mutter. Nut("ISO 4032", "M3", at=(x, y, z), direction="+Z"): liegt mit einer Stirnseite an `at`, `direction`
+ zeigt von dort ins Material (bei einer Mutter unter einer Platte also nach oben).
+
+ standard "ISO 4032" (Sechskant), "ISO 4033" (hoch), "ISO 4035" (flach), "DIN 557" (Vierkant)
+ sunk True: buendig versenkt (aussen an `at`), 0.5: 0,5 mm tiefer. Die Tasche dafuer liefert trap()
+ angle Drehung um die Achse in Grad. Bei 0 liegen zwei Flaechen parallel zur X-Achse (bei Achse X: zur Y-Achse)
+ """
+
+ def __init__(self, standard, size=None, *, at=None, direction=None, on=None, sunk=False, angle=0.0):
+ standard, size = _split_designation(standard, size)
+ self.standard_key = _norm_standard(standard, NUTS, "Mutter")
+ spec = NUTS[self.standard_key]
+ self.standard, self.shape_kind = spec["name"], spec["shape"]
+ self.d, length = _parse_size(size, None, spec["name"])
+ if length is not None:
+ raise ValueError(f"{spec['name']}: Muttern haben keine Laenge, nur \"M{_fmt(self.d)}\" angeben")
+ vals = _lookup(spec["table"], spec["col"], ("m", "s"), self.d, spec["name"])
+ self.height, self.key = vals["m"], vals["s"]
+ sink = _sink(sunk, spec["name"])
+ self.sunk = sink is not None
+ self._place(at, direction, on, angle, self.height + sink if sink is not None else 0.0)
+
+ @property
+ def designation(self):
+ return f"{self.standard} M{_fmt(self.d)}"
+
+ @property
+ def outer(self):
+ return self._local_point(self.height)
+
+ def _local(self):
+ return _nut_local(self.shape_kind, self.d, self.height, self.key)
+
+ def trap(self, clearance=0.2, slot=None, slot_length=None):
+ """Werkzeug fuer cut(): Tasche fuer die Mutter, `clearance` Spiel je Seite und in der Hoehe.
+
+ Versenkte Mutter: offen bis zur Oberflaeche. slot="+X" mit slot_length: Schlitz zum seitlichen Einschieben,
+ so breit wie die Mutter quer zum Schlitz (bei angle=0 und Achse Z ist das fuer "+X" die Schluesselweite).
+ """
+ sc = self.key + 2 * clearance
+ top = self._zs + MARGIN if self.sunk else self.height + clearance
+ pocket = _hex_prism(sc, 0.0, top) if self.shape_kind == "hex" else \
+ cq.Solid.makeBox(sc, sc, top, cq.Vector(-sc / 2, -sc / 2, 0))
+ if slot is not None:
+ if not slot_length or slot_length <= 0:
+ raise ValueError("trap: slot braucht slot_length, die Laenge des Schlitzes ab der Achse in mm")
+ u = _direction(slot)
+ if abs(u.dot(self._dir)) > 1e-6:
+ raise ValueError("trap: slot muss quer zur Achse der Mutter liegen")
+ ux, uy = u.dot(self._plane.xDir), u.dot(self._plane.yDir)
+ if self.shape_kind == "hex":
+ corners = [(sc / COS30 / 2 * math.cos(math.radians(60 * i)), sc / COS30 / 2 * math.sin(math.radians(60 * i)))
+ for i in range(6)]
+ else:
+ corners = [(sx * sc / 2, sy * sc / 2) for sx in (-1, 1) for sy in (-1, 1)]
+ across = [-x * uy + y * ux for x, y in corners]
+ width = max(across) - min(across)
+ box = cq.Solid.makeBox(slot_length, width, top, cq.Vector(0, -width / 2, 0))
+ box = box.rotate(cq.Vector(0, 0, 0), cq.Vector(0, 0, 1), math.degrees(math.atan2(uy, ux)))
+ pocket = pocket.fuse(box)
+ return self._world(_one(pocket))
+
+
+def _ring_local(d1, d2, h):
+ return _one(_cyl(d2, 0, h).cut(_cyl(d1, -0.01, h + 0.01)))
+
+
+class Washer(_Part):
+ """Scheibe. Washer("ISO 7089", "M3", at=(x, y, z)): liegt mit einer Seite an `at`, `outer` ist die andere Seite,
+ auf der dann Kopf oder Mutter sitzt.
+
+ standard "ISO 7089" (normal), "ISO 7091" (grob), "ISO 7093" (gross)
+ """
+
+ def __init__(self, standard, size=None, *, at=None, direction=None, on=None, sunk=False, angle=0.0):
+ standard, size = _split_designation(standard, size)
+ self.standard_key = _norm_standard(standard, WASHERS, "Scheibe")
+ spec = WASHERS[self.standard_key]
+ self.standard = spec["name"]
+ self.d, length = _parse_size(size, None, spec["name"])
+ if length is not None:
+ raise ValueError(f"{spec['name']}: Scheiben haben keine Laenge, nur \"M{_fmt(self.d)}\" angeben")
+ vals = _lookup(spec["table"], spec["col"], ("d1", "d2", "h"), self.d, spec["name"])
+ self.inner, self.outer_diameter, self.thickness = vals["d1"], vals["d2"], vals["h"]
+ sink = _sink(sunk, spec["name"])
+ self.sunk = sink is not None
+ self._place(at, direction, on, angle, self.thickness + sink if sink is not None else 0.0)
+
+ @property
+ def designation(self):
+ return f"{self.standard} M{_fmt(self.d)}"
+
+ @property
+ def outer(self):
+ return self._local_point(self.thickness)
+
+ def _local(self):
+ return _ring_local(self.inner, self.outer_diameter, self.thickness)
+
+
+def _inserts(brand):
+ return _rows("heatset_nut_parameters.csv", brand, ("s", "m", "dc", "drill", "part"))
+
+
+def _insert_local(d, s, m):
+ return _one(_cyl(s, -m, 0).cut(_cyl(d, -m - 0.01, 0.01)))
+
+
+class HeatSetInsert(_Part):
+ """Gewindeeinsatz zum Einschmelzen (3D-Druck). HeatSetInsert("M3x5.7", at=(x, y, z)): die Oberseite schliesst an
+ `at` ab, der Einsatz reicht in Richtung `direction` ins Material. hole() liefert die Bohrung dafuer.
+
+ size "M3x5.7" (Gewinde x Laenge). Ohne Laenge nur, wenn es beim Hersteller nur eine gibt
+ brand "ruthex" (Standard), "CNCKitchen", "McMaster-Carr", "Hilitchi", "AE-SamZhihui"
+ variant bei gleicher Laenge, z. B. "Voron" (ruthex M3x4 mit 5 mm Aussendurchmesser)
+ sunk 0.5: Oberseite 0,5 mm unter `at`
+ """
+
+ color = BRASS
+
+ def __init__(self, size, length=None, *, brand="ruthex", variant=None, at=None, direction=None, on=None, sunk=False,
+ angle=0.0):
+ key = re.sub(r"[\s_.-]", "", str(brand).lower())
+ if key not in INSERT_BRANDS:
+ raise ValueError(f"Gewindeeinsatz: Hersteller {brand!r} unbekannt. Moeglich: "
+ + ", ".join(sorted(set(INSERT_BRANDS.values()))))
+ self.brand = INSERT_BRANDS[key]
+ self.d, length = _parse_size(size, length, "Gewindeeinsatz")
+ rows = [r for r in _inserts(self.brand) if abs(r[0] - self.d) < 1e-9]
+ if not rows:
+ sizes = sorted({r[0] for r in _inserts(self.brand)})
+ raise ValueError(f"Gewindeeinsatz {self.brand}: M{_fmt(self.d)} gibt es nicht. Vorhanden: "
+ + ", ".join(f"M{_fmt(x)}" for x in sizes))
+
+ def label(r): # "5.7", "4 Voron": wie man die Auswahl nennt
+ extra = re.sub(r"^\d+(?:\.\d+)?", "", r[2]).strip(" -")
+ return _fmt(r[3]["m"]) + (f" {extra}" if extra else "")
+
+ found = rows
+ if length is not None:
+ found = [r for r in found if abs(r[3]["m"] - length) < 0.05]
+ if variant is not None:
+ found = [r for r in found if str(variant).lower() in r[2].lower()]
+ elif len(found) > 1: # ohne Variante: die Zeile ohne Zusatz ("4.0", nicht "4.0Voron")
+ plain = [r for r in found if re.fullmatch(r"\d+(?:\.\d+)?", r[2])]
+ found = plain if len(plain) == 1 else found
+ if len(found) != 1:
+ options = ", ".join(sorted({label(r) for r in rows}))
+ what = "passt keiner" if not found else "ist nicht eindeutig"
+ raise ValueError(f"Gewindeeinsatz {self.brand} M{_fmt(self.d)}: {what}. Laengen: {options} "
+ f"(z. B. \"M{_fmt(self.d)}x{label(rows[0]).split()[0]}\", Zusatz mit variant=)")
+ row = found[0][3]
+ self.variant = re.sub(r"^\d+(?:\.\d+)?", "", found[0][2]).strip(" -") or None
+ self.diameter, self.length, self.part_number = row["s"], row["m"], row["part"]
+ self.hole_diameter = _drill_mm(row["drill"])
+ if self.hole_diameter is None or not self.d < self.hole_diameter < self.diameter:
+ raise ValueError(f"{self.designation}: die Tabelle nennt keine brauchbare Bohrung (Bohrer {row['drill']!r}). "
+ "Bohrung beim Hersteller nachsehen, den Einsatz selbst modellieren")
+ sink = _sink(sunk, "Gewindeeinsatz")
+ self.sunk = sink is not None
+ self._place(at, direction, on, angle, sink or 0.0)
+
+ @property
+ def designation(self):
+ return f"Gewindeeinsatz {self.brand} M{_fmt(self.d)}x{_fmt(self.length)}" + (f" {self.variant}" if self.variant else "")
+
+ @property
+ def outer(self):
+ return self._local_point(0.0)
+
+ def _local(self):
+ return _insert_local(self.d, self.diameter, self.length)
+
+ def hole(self, extra_depth=1.0, oversize=0.0):
+ """Werkzeug fuer cut(): Bohrung fuer den Einsatz nach Herstellerangabe, `extra_depth` mm tiefer als der Einsatz
+ lang ist (Platz fuer verdraengten Kunststoff), `oversize` zusaetzlich auf den Durchmesser."""
+ return self._world(_cyl(self.hole_diameter + oversize, -(self.length + extra_depth), self._zs + MARGIN))
diff --git a/python/soma/registry.py b/python/soma/registry.py
index 54b0524..5686fce 100644
--- a/python/soma/registry.py
+++ b/python/soma/registry.py
@@ -5,9 +5,9 @@ import unicodedata
import cadquery as cq
REGISTRY = [] # wird pro Build geleert (siehe build.py)
-DEFAULT_COLORS = {"part": (0.62, 0.66, 0.72), "reference": (0.1, 0.65, 0.3)}
+DEFAULT_COLORS = {"part": (0.62, 0.66, 0.72), "reference": (0.1, 0.65, 0.3), "hardware": (0.45, 0.46, 0.49)}
REFERENCE_ALPHA = 0.45
-ROLES = ("part", "reference")
+ROLES = ("part", "reference", "hardware")
_TRANSLIT = {"ä": "ae", "ö": "oe", "ü": "ue", "Ä": "Ae", "Ö": "Oe", "Ü": "Ue", "ß": "ss", "×": "x"}
@@ -21,6 +21,8 @@ def ascii_name(name):
def to_shape(obj):
+ if hasattr(obj, "__soma_shape__"): # Normteile aus soma.fasteners
+ return obj.__soma_shape__()
if isinstance(obj, cq.Workplane):
vals = obj.vals()
if not vals:
@@ -28,7 +30,7 @@ def to_shape(obj):
return vals[0] if len(vals) == 1 else cq.Compound.makeCompound(vals)
if isinstance(obj, cq.Shape):
return obj
- raise TypeError(f"add_part erwartet cq.Workplane oder cq.Shape, nicht {type(obj).__name__}")
+ raise TypeError(f"add_part erwartet cq.Workplane, cq.Shape oder ein Normteil aus soma.fasteners, nicht {type(obj).__name__}")
def _group_path(group):
@@ -60,16 +62,24 @@ def _unique(name, taken):
return f"{name} ({i})"
-def add_part(name, obj, role="part", color=None, group=None):
+def add_part(name, obj, role=None, color=None, group=None):
"""Registriert ein Bauteil. Pflicht fuer jedes Bauteil, sonst kennen Viewer und Export es nicht.
name eindeutiger Name (Umlaute erlaubt, in der STEP-Datei wird er als ASCII geschrieben)
- obj cq.Workplane oder cq.Shape, oder eine Baugruppe aus import_assembly(): Dann wird jeder Koerper ein eigenes
- Bauteil mit seinem Namen und seiner Farbe, die Unterbaugruppen werden Gruppen unter `name`
- role "part" (Standard) oder "reference" (mitgebrachtes Teil: halbtransparent, eigener Ast, nicht im Export)
- color optional (r, g, b) mit Werten 0..1 (bei einer Baugruppe fuer alle Teile)
+ obj cq.Workplane oder cq.Shape, ein Normteil aus soma.fasteners (Screw, Nut ...) oder eine Baugruppe aus
+ import_assembly(): Dann wird jeder Koerper ein eigenes Bauteil mit seinem Namen und seiner Farbe, die
+ Unterbaugruppen werden Gruppen unter `name`
+ role "part" (eigenes Teil, Standard), "reference" (mitgebrachtes Teil: halbtransparent, eigener Ast, nicht im
+ Export) oder "hardware" (Zukaufteil wie Schrauben: deckend, in der STEP bei seiner Gruppe, nicht in
+ export --all). Normteile aus soma.fasteners sind ohne Angabe "hardware"
+ color optional (r, g, b) mit Werten 0..1 (bei einer Baugruppe fuer alle Teile). Normteile haben eine eigene
group optional, Gruppe im Bauteilbaum und in der STEP-Datei, verschachtelt mit "/", z. B. "Gehaeuse/Schrauben"
"""
+ standard_part = hasattr(obj, "__soma_shape__")
+ if role is None:
+ role = getattr(obj, "role", "part") if standard_part else "part"
+ if color is None and standard_part:
+ color = getattr(obj, "color", None)
if role not in ROLES:
raise ValueError(f"role muss einer von {ROLES} sein, nicht {role!r}")
if not isinstance(name, str) or not name.strip():