cadbuildr-stdlib 0.0.0.1__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.
- cadbuildr_stdlib-0.0.0.1/LICENSE +21 -0
- cadbuildr_stdlib-0.0.0.1/PKG-INFO +11 -0
- cadbuildr_stdlib-0.0.0.1/cadbuildr/__init__.py +0 -0
- cadbuildr_stdlib-0.0.0.1/cadbuildr/stdlib/__init__.py +0 -0
- cadbuildr_stdlib-0.0.0.1/cadbuildr/stdlib/fasterners/nuts/hex_din934.part.py +143 -0
- cadbuildr_stdlib-0.0.0.1/cadbuildr/stdlib/fasterners/screws_and_bolts/__init__.py +0 -0
- cadbuildr_stdlib-0.0.0.1/cadbuildr/stdlib/fasterners/screws_and_bolts/din912.part.py +235 -0
- cadbuildr_stdlib-0.0.0.1/cadbuildr/stdlib/fasterners/threaded_rods/base.part.py +74 -0
- cadbuildr_stdlib-0.0.0.1/cadbuildr/stdlib/fasterners/washers/din125.part.py +70 -0
- cadbuildr_stdlib-0.0.0.1/cadbuildr/stdlib/power_transmission/shafts/base.part.py +21 -0
- cadbuildr_stdlib-0.0.0.1/pyproject.toml +16 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 cadbuildr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: cadbuildr-stdlib
|
|
3
|
+
Version: 0.0.0.1
|
|
4
|
+
Summary: Standard library for cadbuildr with tools, parts, assemblies built on top of foundation
|
|
5
|
+
Author: Cadbuildr Team
|
|
6
|
+
Requires-Python: >=3.10,<4.0
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Requires-Dist: cadbuildr-foundation (>=0.0.0.13,<0.0.1.0)
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
from cadbuildr.foundation import *
|
|
2
|
+
import math
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class HexNut(Part):
|
|
6
|
+
def __init__(self, size, with_thread=True):
|
|
7
|
+
self.size = size
|
|
8
|
+
self.with_thread = with_thread
|
|
9
|
+
|
|
10
|
+
dimensions = self.dimension_table[size]
|
|
11
|
+
self.width_across_flats = dimensions["width_across_flats"] # WAF
|
|
12
|
+
self.thickness = dimensions["thickness"]
|
|
13
|
+
self.nominal_diameter = dimensions["nominal_diameter"]
|
|
14
|
+
self.thread_pitch = dimensions["thread_pitch"]
|
|
15
|
+
|
|
16
|
+
self.get_body_sketch()
|
|
17
|
+
if self.with_thread:
|
|
18
|
+
self.add_thread()
|
|
19
|
+
self.paint("grey")
|
|
20
|
+
|
|
21
|
+
dimension_table = {
|
|
22
|
+
"M3": {
|
|
23
|
+
"width_across_flats": 5.5,
|
|
24
|
+
"thickness": 2.4,
|
|
25
|
+
"nominal_diameter": 3,
|
|
26
|
+
"thread_pitch": 0.5,
|
|
27
|
+
},
|
|
28
|
+
"M4": {
|
|
29
|
+
"width_across_flats": 7.0,
|
|
30
|
+
"thickness": 3.2,
|
|
31
|
+
"nominal_diameter": 4,
|
|
32
|
+
"thread_pitch": 0.7,
|
|
33
|
+
},
|
|
34
|
+
"M5": {
|
|
35
|
+
"width_across_flats": 8.0,
|
|
36
|
+
"thickness": 4.0,
|
|
37
|
+
"nominal_diameter": 5,
|
|
38
|
+
"thread_pitch": 0.8,
|
|
39
|
+
},
|
|
40
|
+
"M6": {
|
|
41
|
+
"width_across_flats": 10.0,
|
|
42
|
+
"thickness": 5.0,
|
|
43
|
+
"nominal_diameter": 6,
|
|
44
|
+
"thread_pitch": 1.0,
|
|
45
|
+
},
|
|
46
|
+
"M8": {
|
|
47
|
+
"width_across_flats": 13.0,
|
|
48
|
+
"thickness": 6.5,
|
|
49
|
+
"nominal_diameter": 8,
|
|
50
|
+
"thread_pitch": 1.25,
|
|
51
|
+
},
|
|
52
|
+
"M10": {
|
|
53
|
+
"width_across_flats": 16.0,
|
|
54
|
+
"thickness": 8.0,
|
|
55
|
+
"nominal_diameter": 10,
|
|
56
|
+
"thread_pitch": 1.5,
|
|
57
|
+
},
|
|
58
|
+
"M12": {
|
|
59
|
+
"width_across_flats": 18.0,
|
|
60
|
+
"thickness": 10.0,
|
|
61
|
+
"nominal_diameter": 12,
|
|
62
|
+
"thread_pitch": 1.75,
|
|
63
|
+
},
|
|
64
|
+
"M14": {
|
|
65
|
+
"width_across_flats": 21.0,
|
|
66
|
+
"thickness": 11.0,
|
|
67
|
+
"nominal_diameter": 14,
|
|
68
|
+
"thread_pitch": 2.0,
|
|
69
|
+
},
|
|
70
|
+
"M16": {
|
|
71
|
+
"width_across_flats": 24.0,
|
|
72
|
+
"thickness": 13.0,
|
|
73
|
+
"nominal_diameter": 16,
|
|
74
|
+
"thread_pitch": 2.0,
|
|
75
|
+
},
|
|
76
|
+
"M20": {
|
|
77
|
+
"width_across_flats": 30.0,
|
|
78
|
+
"thickness": 16.0,
|
|
79
|
+
"nominal_diameter": 20,
|
|
80
|
+
"thread_pitch": 2.5,
|
|
81
|
+
},
|
|
82
|
+
"M24": {
|
|
83
|
+
"width_across_flats": 36.0,
|
|
84
|
+
"thickness": 19.0,
|
|
85
|
+
"nominal_diameter": 24,
|
|
86
|
+
"thread_pitch": 3.0,
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
def get_body_sketch(self):
|
|
91
|
+
sketch = Sketch(self.xy())
|
|
92
|
+
|
|
93
|
+
side_length = self.width_across_flats / math.sqrt(3)
|
|
94
|
+
|
|
95
|
+
for i in range(6):
|
|
96
|
+
angle = math.radians(60 * i)
|
|
97
|
+
x = side_length * math.cos(angle)
|
|
98
|
+
y = side_length * math.sin(angle)
|
|
99
|
+
if i == 0:
|
|
100
|
+
sketch.pencil.move_to(x, y)
|
|
101
|
+
else:
|
|
102
|
+
sketch.pencil.line_to(x, y)
|
|
103
|
+
|
|
104
|
+
hexagon_shape = sketch.pencil.close()
|
|
105
|
+
e = Extrusion(hexagon_shape, self.thickness)
|
|
106
|
+
self.add_operation(e)
|
|
107
|
+
|
|
108
|
+
# Cut the inner cylindrical hole
|
|
109
|
+
hole_center = Point(sketch, 0, 0)
|
|
110
|
+
hole = Circle(hole_center, self.nominal_diameter / 2)
|
|
111
|
+
cut_op = Extrusion(hole, self.thickness, cut=True)
|
|
112
|
+
self.add_operation(cut_op)
|
|
113
|
+
|
|
114
|
+
def add_thread(self):
|
|
115
|
+
thread_height = self.thickness
|
|
116
|
+
H = self.thread_pitch * math.sqrt(3) / 2
|
|
117
|
+
thread_radius = self.nominal_diameter / 2 + H / 4
|
|
118
|
+
|
|
119
|
+
path = Helix3D(
|
|
120
|
+
self.thread_pitch,
|
|
121
|
+
thread_height - self.thread_pitch,
|
|
122
|
+
thread_radius,
|
|
123
|
+
center=Point3D(0, 0, self.thread_pitch / 2),
|
|
124
|
+
dir=Point3D(0, 0, 1),
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
profile = self.get_thread_profile(self.thread_pitch)
|
|
128
|
+
sweep = Sweep(profile, path)
|
|
129
|
+
self.add_operation(sweep)
|
|
130
|
+
|
|
131
|
+
def get_thread_profile(self, pitch):
|
|
132
|
+
H = pitch * math.sqrt(3) / 2
|
|
133
|
+
s = Sketch(self.xz())
|
|
134
|
+
s.pencil.move_to(0, -pitch / 2 + pitch / 16)
|
|
135
|
+
s.pencil.line_to(-5 / 8 * H, -pitch / 8)
|
|
136
|
+
s.pencil.line(0, pitch / 4)
|
|
137
|
+
s.pencil.line_to(0, pitch / 2 - pitch / 16)
|
|
138
|
+
profile = s.pencil.close()
|
|
139
|
+
return profile
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
if __name__ == "__main__":
|
|
143
|
+
show(HexNut(size="M6", with_thread=True))
|
|
File without changes
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
from cadbuildr.foundation import (
|
|
2
|
+
Helix3D,
|
|
3
|
+
Sweep,
|
|
4
|
+
Part,
|
|
5
|
+
Sketch,
|
|
6
|
+
Axis,
|
|
7
|
+
Line,
|
|
8
|
+
Extrusion,
|
|
9
|
+
Point,
|
|
10
|
+
Lathe,
|
|
11
|
+
show,
|
|
12
|
+
Point3D,
|
|
13
|
+
)
|
|
14
|
+
import math
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Screw(Part):
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
head_radius=10,
|
|
21
|
+
head_height=5,
|
|
22
|
+
body_radius=5,
|
|
23
|
+
body_height=30,
|
|
24
|
+
hexagon_width=7.5,
|
|
25
|
+
hexagon_depth=3,
|
|
26
|
+
thread_pitch=1.25,
|
|
27
|
+
with_thread=True,
|
|
28
|
+
):
|
|
29
|
+
self.head_radius = head_radius
|
|
30
|
+
self.head_height = head_height
|
|
31
|
+
self.body_radius = body_radius
|
|
32
|
+
self.body_height = body_height
|
|
33
|
+
self.hexagon_width = hexagon_width
|
|
34
|
+
self.hexagon_depth = hexagon_depth
|
|
35
|
+
self.thread_pitch = thread_pitch
|
|
36
|
+
self.with_thread = with_thread
|
|
37
|
+
|
|
38
|
+
self.get_body_sketch()
|
|
39
|
+
self.get_hexagonal_cut()
|
|
40
|
+
|
|
41
|
+
if with_thread:
|
|
42
|
+
self.add_thread()
|
|
43
|
+
self.paint("grey")
|
|
44
|
+
|
|
45
|
+
def get_body_sketch(self):
|
|
46
|
+
s = Sketch(self.xz())
|
|
47
|
+
H = self.thread_pitch * math.sqrt(3) / 2
|
|
48
|
+
|
|
49
|
+
effective_body_radius = self.body_radius
|
|
50
|
+
if self.with_thread:
|
|
51
|
+
DELTA = 0.01
|
|
52
|
+
effective_body_radius -= H / 4 + DELTA
|
|
53
|
+
|
|
54
|
+
s.pencil.line(effective_body_radius, 0)
|
|
55
|
+
s.pencil.line(0, self.body_height)
|
|
56
|
+
s.pencil.line_to(self.head_radius, self.body_height)
|
|
57
|
+
s.pencil.line(0, self.head_height)
|
|
58
|
+
s.pencil.line_to(0, self.body_height + self.head_height)
|
|
59
|
+
s.pencil.close()
|
|
60
|
+
|
|
61
|
+
shape = s.pencil.get_closed_shape()
|
|
62
|
+
axis = Axis(Line(s.origin, Point(s, 0, self.body_height + self.head_height)))
|
|
63
|
+
self.add_operation(Lathe(shape, axis))
|
|
64
|
+
|
|
65
|
+
def get_hexagonal_cut(self):
|
|
66
|
+
sketch = Sketch(self.xy())
|
|
67
|
+
|
|
68
|
+
# Calculate the side length of the hexagon
|
|
69
|
+
side_length = self.hexagon_width / math.sqrt(3)
|
|
70
|
+
|
|
71
|
+
for i in range(6):
|
|
72
|
+
angle = math.radians(60 * i)
|
|
73
|
+
x = side_length * math.cos(angle)
|
|
74
|
+
y = side_length * math.sin(angle)
|
|
75
|
+
if i == 0:
|
|
76
|
+
sketch.pencil.move_to(x, y)
|
|
77
|
+
else:
|
|
78
|
+
sketch.pencil.line_to(x, y)
|
|
79
|
+
|
|
80
|
+
hexagon_shape = sketch.pencil.close()
|
|
81
|
+
|
|
82
|
+
cut_e = Extrusion(
|
|
83
|
+
hexagon_shape,
|
|
84
|
+
self.body_height + self.head_height - self.hexagon_depth,
|
|
85
|
+
self.body_height + self.head_height,
|
|
86
|
+
cut=True,
|
|
87
|
+
)
|
|
88
|
+
self.add_operation(cut_e)
|
|
89
|
+
|
|
90
|
+
def add_thread(self):
|
|
91
|
+
thread_height = self.body_height
|
|
92
|
+
H = self.thread_pitch * math.sqrt(3) / 2
|
|
93
|
+
|
|
94
|
+
thread_radius = self.body_radius - H / 4
|
|
95
|
+
|
|
96
|
+
path = Helix3D(
|
|
97
|
+
self.thread_pitch,
|
|
98
|
+
thread_height - self.thread_pitch,
|
|
99
|
+
thread_radius,
|
|
100
|
+
center=Point3D(0, 0, self.thread_pitch / 2),
|
|
101
|
+
dir=Point3D(0, 0, 1),
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
profile = self.get_thread_profile(self.thread_pitch)
|
|
105
|
+
sweep = Sweep(profile, path)
|
|
106
|
+
self.add_operation(sweep)
|
|
107
|
+
|
|
108
|
+
def get_thread_profile(self, pitch):
|
|
109
|
+
"""https://en.wikipedia.org/wiki/Screw_thread#/media/File:ISO_and_UTS_Thread_Dimensions.svg"""
|
|
110
|
+
H = pitch * math.sqrt(3) / 2
|
|
111
|
+
s = Sketch(self.xz())
|
|
112
|
+
s.pencil.line_to(0, -pitch / 2 + pitch / 16)
|
|
113
|
+
s.pencil.line_to(5 / 8 * H, -pitch / 8)
|
|
114
|
+
s.pencil.line(0, pitch / 4)
|
|
115
|
+
s.pencil.line_to(0, pitch / 2 - pitch / 16)
|
|
116
|
+
profile = s.pencil.close()
|
|
117
|
+
|
|
118
|
+
# profile = s.pencil.close_with_mirror()
|
|
119
|
+
return profile
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# Define the DIN912Screw class
|
|
123
|
+
class DIN912Screw(Screw):
|
|
124
|
+
# Class constant: dimension table
|
|
125
|
+
dimension_table = {
|
|
126
|
+
"M3": {
|
|
127
|
+
"head_diameter": 5.5,
|
|
128
|
+
"head_height": 3,
|
|
129
|
+
"hexagon_width": 2.5, # H2.5
|
|
130
|
+
"hexagon_depth": 1.3,
|
|
131
|
+
"thread_pitch": 0.5,
|
|
132
|
+
},
|
|
133
|
+
"M4": {
|
|
134
|
+
"head_diameter": 7.0,
|
|
135
|
+
"head_height": 4,
|
|
136
|
+
"hexagon_width": 3,
|
|
137
|
+
"hexagon_depth": 2,
|
|
138
|
+
"thread_pitch": 0.7,
|
|
139
|
+
},
|
|
140
|
+
"M5": {
|
|
141
|
+
"head_diameter": 8.5,
|
|
142
|
+
"head_height": 5,
|
|
143
|
+
"hexagon_width": 4,
|
|
144
|
+
"hexagon_depth": 2.5,
|
|
145
|
+
"thread_pitch": 0.8,
|
|
146
|
+
},
|
|
147
|
+
"M6": {
|
|
148
|
+
"head_diameter": 10.0,
|
|
149
|
+
"head_height": 6,
|
|
150
|
+
"hexagon_width": 5,
|
|
151
|
+
"hexagon_depth": 3,
|
|
152
|
+
"thread_pitch": 1.0,
|
|
153
|
+
},
|
|
154
|
+
"M8": {
|
|
155
|
+
"head_diameter": 13.0,
|
|
156
|
+
"head_height": 8,
|
|
157
|
+
"hexagon_width": 6,
|
|
158
|
+
"hexagon_depth": 4,
|
|
159
|
+
"thread_pitch": 1.25,
|
|
160
|
+
},
|
|
161
|
+
"M10": {
|
|
162
|
+
"head_diameter": 16.0,
|
|
163
|
+
"head_height": 10,
|
|
164
|
+
"hexagon_width": 8,
|
|
165
|
+
"hexagon_depth": 5,
|
|
166
|
+
"thread_pitch": 1.5,
|
|
167
|
+
},
|
|
168
|
+
"M12": {
|
|
169
|
+
"head_diameter": 18.0,
|
|
170
|
+
"head_height": 12,
|
|
171
|
+
"hexagon_width": 10,
|
|
172
|
+
"hexagon_depth": 6,
|
|
173
|
+
"thread_pitch": 1.75,
|
|
174
|
+
},
|
|
175
|
+
"M14": {
|
|
176
|
+
"head_diameter": 21.0,
|
|
177
|
+
"head_height": 14,
|
|
178
|
+
"hexagon_width": 12,
|
|
179
|
+
"hexagon_depth": 7,
|
|
180
|
+
"thread_pitch": 2.0,
|
|
181
|
+
},
|
|
182
|
+
"M16": {
|
|
183
|
+
"head_diameter": 24.0,
|
|
184
|
+
"head_height": 16,
|
|
185
|
+
"hexagon_width": 14,
|
|
186
|
+
"hexagon_depth": 8,
|
|
187
|
+
"thread_pitch": 2.0,
|
|
188
|
+
},
|
|
189
|
+
"M20": {
|
|
190
|
+
"head_diameter": 30.0,
|
|
191
|
+
"head_height": 20,
|
|
192
|
+
"hexagon_width": 17,
|
|
193
|
+
"hexagon_depth": 10,
|
|
194
|
+
"thread_pitch": 2.5,
|
|
195
|
+
},
|
|
196
|
+
"M24": {
|
|
197
|
+
"head_diameter": 36.0,
|
|
198
|
+
"head_height": 24,
|
|
199
|
+
"hexagon_width": 19,
|
|
200
|
+
"hexagon_depth": 12,
|
|
201
|
+
"thread_pitch": 3.0,
|
|
202
|
+
},
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
def __init__(self, size, length, with_thread=True):
|
|
206
|
+
if size not in self.dimension_table:
|
|
207
|
+
raise ValueError(f"Size '{size}' not found in dimension table.")
|
|
208
|
+
|
|
209
|
+
# Retrieve dimensions from the table
|
|
210
|
+
dimensions = self.dimension_table[size]
|
|
211
|
+
|
|
212
|
+
# Calculate body diameter from size
|
|
213
|
+
body_diameter = float(
|
|
214
|
+
size[1:]
|
|
215
|
+
) # Extract diameter from size string, e.g., 'M6' -> 6.0
|
|
216
|
+
|
|
217
|
+
# Call the superclass constructor with the retrieved dimensions
|
|
218
|
+
super().__init__(
|
|
219
|
+
head_radius=dimensions["head_diameter"] / 2,
|
|
220
|
+
head_height=dimensions["head_height"],
|
|
221
|
+
body_radius=body_diameter / 2,
|
|
222
|
+
body_height=length - dimensions["head_height"],
|
|
223
|
+
hexagon_width=dimensions["hexagon_width"],
|
|
224
|
+
hexagon_depth=dimensions["hexagon_depth"],
|
|
225
|
+
thread_pitch=dimensions["thread_pitch"],
|
|
226
|
+
with_thread=with_thread,
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
# Store additional attributes specific to DIN912Screw
|
|
230
|
+
self.size = size
|
|
231
|
+
self.length = length
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
if __name__ == "__main__":
|
|
235
|
+
show(DIN912Screw(size="M6", length=20, with_thread=True))
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# %%
|
|
2
|
+
from cadbuildr.foundation import (
|
|
3
|
+
Part,
|
|
4
|
+
Sketch,
|
|
5
|
+
Point,
|
|
6
|
+
Circle,
|
|
7
|
+
Extrusion,
|
|
8
|
+
show,
|
|
9
|
+
Axis,
|
|
10
|
+
Line,
|
|
11
|
+
Lathe,
|
|
12
|
+
Sweep,
|
|
13
|
+
Helix3D,
|
|
14
|
+
Point3D,
|
|
15
|
+
)
|
|
16
|
+
import math
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ThreadedRod(Part):
|
|
20
|
+
def __init__(self, diameter, length, thread_pitch=1.25, with_thread=True):
|
|
21
|
+
self.diameter = diameter
|
|
22
|
+
self.length = length
|
|
23
|
+
self.thread_pitch = thread_pitch
|
|
24
|
+
self.with_thread = with_thread
|
|
25
|
+
|
|
26
|
+
self.create_body()
|
|
27
|
+
|
|
28
|
+
if with_thread:
|
|
29
|
+
self.add_thread()
|
|
30
|
+
|
|
31
|
+
def create_body(self):
|
|
32
|
+
s = Sketch(self.xz())
|
|
33
|
+
radius = self.diameter / 2
|
|
34
|
+
|
|
35
|
+
s.pencil.line(radius, 0)
|
|
36
|
+
s.pencil.line(0, self.length)
|
|
37
|
+
s.pencil.line_to(0, self.length)
|
|
38
|
+
s.pencil.line_to(0, 0)
|
|
39
|
+
s.pencil.close()
|
|
40
|
+
|
|
41
|
+
shape = s.pencil.get_closed_shape()
|
|
42
|
+
axis = Axis(Line(s.origin, Point(s, 0, self.length)))
|
|
43
|
+
self.add_operation(Lathe(shape, axis))
|
|
44
|
+
|
|
45
|
+
def add_thread(self):
|
|
46
|
+
# TODO simplify once threads are available in the foundation lib.
|
|
47
|
+
thread_height = self.length
|
|
48
|
+
H = self.thread_pitch * math.sqrt(3) / 2
|
|
49
|
+
|
|
50
|
+
thread_radius = self.diameter / 2 - H / 4
|
|
51
|
+
|
|
52
|
+
s = Sketch(self.xz())
|
|
53
|
+
s.pencil.line_to(0, -self.thread_pitch / 2 + self.thread_pitch / 16)
|
|
54
|
+
s.pencil.line_to(5 / 8 * H, -self.thread_pitch / 8)
|
|
55
|
+
s.pencil.line(0, self.thread_pitch / 4)
|
|
56
|
+
s.pencil.line_to(0, self.thread_pitch / 2 - self.thread_pitch / 16)
|
|
57
|
+
|
|
58
|
+
profile = s.pencil.close()
|
|
59
|
+
|
|
60
|
+
path = Helix3D(
|
|
61
|
+
self.thread_pitch,
|
|
62
|
+
thread_height - self.thread_pitch,
|
|
63
|
+
thread_radius,
|
|
64
|
+
center=Point3D(0, 0, self.thread_pitch / 2),
|
|
65
|
+
dir=Point3D(0, 0, 1),
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
sweep = Sweep(profile, path)
|
|
69
|
+
self.add_operation(sweep)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if __name__ == "__main__":
|
|
73
|
+
show(ThreadedRod(diameter=5, length=30, thread_pitch=1.5, with_thread=True))
|
|
74
|
+
# %%
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from cadbuildr.foundation import Part, Sketch, Circle, Extrusion, show
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Washer(Part):
|
|
5
|
+
def __init__(self, outer_radius=20, inner_radius=10, thickness=2):
|
|
6
|
+
self.outer_radius = outer_radius
|
|
7
|
+
self.inner_radius = inner_radius
|
|
8
|
+
self.thickness = thickness
|
|
9
|
+
|
|
10
|
+
self.create_washer()
|
|
11
|
+
|
|
12
|
+
def create_washer(self):
|
|
13
|
+
s = Sketch(self.xy())
|
|
14
|
+
|
|
15
|
+
# Create outer circle
|
|
16
|
+
outer_circle = Circle(s.origin, self.outer_radius)
|
|
17
|
+
|
|
18
|
+
# Extrude the outer circle to create the washer base
|
|
19
|
+
e_outer = Extrusion(outer_circle, self.thickness)
|
|
20
|
+
self.add_operation(e_outer)
|
|
21
|
+
|
|
22
|
+
# Create inner circle
|
|
23
|
+
inner_circle = Circle(s.origin, self.inner_radius)
|
|
24
|
+
|
|
25
|
+
# Extrude the inner circle with cut=True to create the hole
|
|
26
|
+
e_inner = Extrusion(inner_circle, self.thickness, cut=True)
|
|
27
|
+
self.add_operation(e_inner)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class DIN125Washer(Washer):
|
|
31
|
+
DIN_SPECS = {
|
|
32
|
+
"M1.6": {"outer_diameter": 4, "inner_radius": 1.7 / 2, "thickness": 0.3},
|
|
33
|
+
"M2": {"outer_diameter": 5, "inner_radius": 2.2 / 2, "thickness": 0.3},
|
|
34
|
+
"M2.5": {"outer_diameter": 6, "inner_radius": 2.7 / 2, "thickness": 0.5},
|
|
35
|
+
"M3": {"outer_diameter": 7, "inner_radius": 3.2 / 2, "thickness": 0.5},
|
|
36
|
+
"M4": {"outer_diameter": 9, "inner_radius": 4.3 / 2, "thickness": 0.8},
|
|
37
|
+
"M5": {"outer_diameter": 10, "inner_radius": 5.3 / 2, "thickness": 1},
|
|
38
|
+
"M6": {"outer_diameter": 12, "inner_radius": 6.4 / 2, "thickness": 1.6},
|
|
39
|
+
"M7": {"outer_diameter": 14, "inner_radius": 7.4 / 2, "thickness": 1.6},
|
|
40
|
+
"M8": {"outer_diameter": 16, "inner_radius": 8.4 / 2, "thickness": 1.6},
|
|
41
|
+
"M10": {"outer_diameter": 20, "inner_radius": 10.5 / 2, "thickness": 2},
|
|
42
|
+
"M12": {"outer_diameter": 24, "inner_radius": 13 / 2, "thickness": 2.5},
|
|
43
|
+
"M14": {"outer_diameter": 28, "inner_radius": 15 / 2, "thickness": 2.5},
|
|
44
|
+
"M16": {"outer_diameter": 30, "inner_radius": 17 / 2, "thickness": 3},
|
|
45
|
+
"M18": {"outer_diameter": 34, "inner_radius": 19 / 2, "thickness": 3},
|
|
46
|
+
"M20": {"outer_diameter": 37, "inner_radius": 21 / 2, "thickness": 3},
|
|
47
|
+
"M22": {"outer_diameter": 39, "inner_radius": 23 / 2, "thickness": 3},
|
|
48
|
+
"M24": {"outer_diameter": 44, "inner_radius": 25 / 2, "thickness": 4},
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
def __init__(self, size):
|
|
52
|
+
if size not in self.DIN_SPECS:
|
|
53
|
+
raise ValueError(f"Size '{size}' not found in DIN specifications.")
|
|
54
|
+
|
|
55
|
+
# Retrieve dimensions from the DIN specifications
|
|
56
|
+
specs = self.DIN_SPECS[size]
|
|
57
|
+
|
|
58
|
+
# Call the superclass constructor with the retrieved dimensions
|
|
59
|
+
super().__init__(
|
|
60
|
+
outer_radius=specs["outer_diameter"] / 2,
|
|
61
|
+
inner_radius=specs["inner_radius"],
|
|
62
|
+
thickness=specs["thickness"],
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# Store additional attributes specific to DIN125Washer
|
|
66
|
+
self.size = size
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if __name__ == "__main__":
|
|
70
|
+
show(DIN125Washer(size="M6"))
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# %%
|
|
2
|
+
from cadbuildr.foundation import Part, Sketch, Point, Circle, Extrusion, show
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Shaft(Part):
|
|
6
|
+
def __init__(self, diameter=10, length=100):
|
|
7
|
+
self.DIAMETER = diameter
|
|
8
|
+
self.LENGTH = length
|
|
9
|
+
self.create_shaft()
|
|
10
|
+
|
|
11
|
+
def create_shaft(self):
|
|
12
|
+
s = Sketch(self.xy())
|
|
13
|
+
center = Point(s, 0, 0)
|
|
14
|
+
circle = Circle(center, self.DIAMETER / 2)
|
|
15
|
+
extrusion = Extrusion(circle, self.LENGTH)
|
|
16
|
+
self.add_operation(extrusion)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
if __name__ == "__main__":
|
|
20
|
+
show(Shaft())
|
|
21
|
+
# %%
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "cadbuildr-stdlib"
|
|
3
|
+
version = "0.0.0.1"
|
|
4
|
+
description = "Standard library for cadbuildr with tools, parts, assemblies built on top of foundation"
|
|
5
|
+
authors = ["Cadbuildr Team"]
|
|
6
|
+
packages = [
|
|
7
|
+
{ include = "cadbuildr" }
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
[tool.poetry.dependencies]
|
|
12
|
+
python = "^3.10"
|
|
13
|
+
cadbuildr-foundation = "^0.0.0.13"
|
|
14
|
+
|
|
15
|
+
[tool.cadbuildr.dependencies]
|
|
16
|
+
foundation = "^0.0.0.13"
|