1+ from madcad import *
2+ from madcad .gear import *
3+
4+ # bevelgear with annotations
5+ def sbevelgear (step , z , pitch_cone_angle , ** kwargs ):
6+ part = bevelgear (step , z , pitch_cone_angle , ** kwargs )
7+ top = project (part .group (4 ).barycenter (), Z )
8+ bot = project (part .group (1 ).barycenter (), Z )
9+ return Solid (
10+ part = part .option (color = gear_color ),
11+ summit = O ,
12+ axis = Axis (top , - Z , interval = (0 , length (top ))),
13+ bot = Axis (bot , Z , interval = (0 , length (top - bot ))),
14+ annotations = [
15+ note_radius (part .group (part .groupnear (top + z * step * X ))),
16+ note_radius (part .group (part .groupnear (mix (top , bot , 0.5 )))),
17+ ],
18+ )
19+
20+ # bolt with annotations
21+ def bolt (a , b , dscrew , washera = False , washerb = False ):
22+ dir = normalize (b - a )
23+ rwasher = washer (dscrew )
24+ thickness = rwasher ['part' ].box ().width .z
25+ rscrew = screw (dscrew , stceil (distance (a ,b ) + 1.2 * dscrew , precision = 0.2 ))
26+ rnut = nut (dscrew )
27+ rscrew ['annotations' ] = [
28+ note_distance (O , - stceil (distance (a ,b ) + 1.2 * dscrew )* Z , offset = 2 * dscrew * X ),
29+ note_radius (rscrew ['part' ].group (0 )),
30+ ]
31+ return Solid (
32+ screw = rscrew .place ((Pivot , rscrew ['axis' ], Axis (a - thickness * dir , - dir ))),
33+ nut = rnut .place ((Pivot , rnut ['top' ], Axis (b + thickness * dir , - dir ))),
34+ w1 = rwasher .place ((Pivot , rwasher ['top' ], Axis (b , - dir ))),
35+ w2 = rwasher .place ((Pivot , rwasher ['top' ], Axis (a , dir ))),
36+ )
37+
38+
39+
40+ #settings.primitives['curve_resolution'] = ('rad', 0.105)
41+ settings .primitives ['curve_resolution' ] = ('rad' , 0.19456 )
42+
43+ transmiter_angle = pi / 6
44+ transmiter_z = 8
45+ gear_step = 6
46+ output_radius = 5
47+ gear_color = vec3 (0.2 , 0.3 , 0.4 )
48+ shell_thickness = 1
49+ dscrew = 3
50+ helix_angle = 0 #radians(-20)
51+
52+ axis_z = round (transmiter_z / tan (transmiter_angle ))
53+ transmiter_rint = stceil ((transmiter_z * gear_step / (2 * pi ) - 0.6 * gear_step ) * (0.5 + 0.2 * sin (transmiter_angle )))
54+
55+ # mechanism
56+ # interface shafts
57+ bearing_height = stceil (output_radius )
58+ bearing_radius = stceil (output_radius * 2.5 )
59+ out_gear = sbevelgear (gear_step , axis_z , pi / 2 - transmiter_angle ,
60+ bore_radius = output_radius ,
61+ bore_height = 1.2 * bearing_height ,
62+ helix_angle = helix_angle ,
63+ )
64+ output = Solid (
65+ gear = out_gear ,
66+ bearing = bearing (stceil (output_radius * 1.5 * 2 ), bearing_radius * 2 , bearing_height )
67+ .transform (out_gear ['axis' ].origin - 0.5 * bearing_height * Z ),
68+ )
69+ output1 = output
70+ output2 = output .transform (rotate (pi ,Y ))
71+
72+ # internal transmission shafts
73+ transmiter_axis_thickness = stceil (transmiter_rint * 0.4 )
74+ transmiter_washer_thickness = stceil (transmiter_rint * 0.2 )
75+ transmiter_gear = sbevelgear (gear_step , transmiter_z , transmiter_angle ,
76+ bore_height = 0 ,
77+ bore_radius = transmiter_rint * 1.05 ,
78+ helix_angle = - helix_angle ,
79+ )
80+ transmiter = Solid (
81+ gear = transmiter_gear ,
82+ bearing = slidebearing (
83+ (transmiter_rint - transmiter_axis_thickness )* 2 ,
84+ stceil (distance (transmiter_gear ['axis' ].origin , transmiter_gear ['bot' ].origin ) + 2 * transmiter_rint ),
85+ transmiter_axis_thickness ,
86+ ) .transform (translate (transmiter_gear ['bot' ].origin ) * rotate (pi ,X )),
87+ washer = washer (
88+ stceil (transmiter_rint * 2 ),
89+ stceil (transmiter_rint * 1.8 * 2 ),
90+ transmiter_washer_thickness ,
91+ ) .transform (transmiter_gear ['axis' ].origin ),
92+ ).transform (rotate (pi / 2 ,Y ))
93+
94+ transmiter_amount = ceil (axis_z / (1.5 * transmiter_z / pi ))
95+ transmiters = [transmiter .transform (rotate (i * 2 * pi / transmiter_amount ,Z )) for i in range (transmiter_amount )]
96+
97+ space_radius = transmiter_z * gear_step / (2 * pi ) / sin (transmiter_angle ) + transmiter_washer_thickness
98+
99+ # interior shell
100+ interior_top = revolution (2 * pi , Axis (O ,Z ), Wire ([
101+ out_gear ['axis' ].origin + bearing_radius * X - bearing_radius * 0.15 * X ,
102+ out_gear ['axis' ].origin + bearing_radius * X ,
103+ out_gear ['axis' ].origin + bearing_radius * X - bearing_height * Z ,
104+ out_gear ['axis' ].origin + bearing_radius * X - bearing_height * 1.2 * Z + bearing_height * 0.2 * X ,
105+ out_gear ['axis' ].origin + space_radius * X - bearing_height * 1.2 * Z ,
106+ ]).flip ().segmented ())
107+ interior_out = (
108+ interior_top
109+ + interior_top .transform (scaledir (Z ,- 1 )).flip ()
110+ ).finish ()
111+
112+ r = length (transmiter ['gear' ]['axis' ].origin )
113+ h = transmiter_rint
114+ w = r + transmiter_washer_thickness * 1.5
115+ interior_transmision = revolution (2 * pi , Axis (O ,X ), Wire ([
116+ 2 * r * X + h * Z ,
117+ w * X + h * Z ,
118+ w * X + 2.5 * h * Z ,
119+ w * X + 2.5 * h * Z + h * (X + Z ),
120+ ]).flip ().segmented ())
121+ interior_transmisions = repeat (interior_transmision , transmiter_amount , rotate (2 * pi / transmiter_amount , Z ))
122+
123+ interior_space = union (
124+ icosphere (O , space_radius ),
125+ cylinder (out_gear ['axis' ].origin , out_gear ['axis' ].origin * vec3 (1 ,1 ,- 1 ), bearing_radius * 1.05 , fill = False ),
126+ ).flip ()
127+
128+ interior_shell = union (interior_space , interior_out )
129+ interior = union (interior_shell , interior_transmisions .group ({0 ,1 })) + interior_transmisions .group ({2 ,3 ,4 ,5 })
130+
131+ # asymetrical exterior shell
132+ exterior_shell = inflate (interior_shell .flip (), shell_thickness )
133+
134+ # interface shape and botls
135+ mount_thickness = 4 * shell_thickness
136+ neighscrew = 1.4 * dscrew
137+ rscrew = stceil (max (bearing_radius + 1.2 * neighscrew , space_radius + dscrew * 0.5 + shell_thickness * 0.5 ), precision = 0.1 )
138+ a = out_gear ['axis' ].origin + rscrew * X + shell_thickness * Z
139+ b = a - mount_thickness * Z
140+ bolt = bolt (a , b , dscrew , False , False )
141+ bolts = [bolt .transform (rotate ((i + 0.5 )* 2 * pi / 8 , Z )) for i in range (8 )]
142+
143+ screw_support = revolution (2 * pi , Axis (O ,Z ), wire (
144+ Wire ([
145+ project (a , Z ),
146+ a + 1.3 * dscrew * X ,
147+ ]).segmented (),
148+ Softened ([
149+ b + 1.3 * dscrew * X ,
150+ project (b , Z ) + space_radius * X ,
151+ space_radius * X ,
152+ ]),
153+ ))
154+ slot = cylinder (b + 1e-2 * Z , noproject (b , Z ), neighscrew ).flip ()
155+ slots = mesh .mesh ([slot .transform (b .pose ) for b in bolts ])
156+ head = intersection (screw_support , slots )
157+
158+ l = length (transmiter ['gear' ]['axis' ].origin ) + 2 * transmiter_rint
159+ transmiter_back = revolution (2 * pi , Axis (O ,Z ), Wire ([
160+ l * Z ,
161+ l * Z + transmiter_rint * 1.5 * X ,
162+ rotate (pi / 6 , Y ) * space_radius * Z ,
163+ ]).segmented ()) .transform (rotate (pi / 2 , Y ))
164+
165+ exterior_shell = union (
166+ exterior_shell ,
167+ mesh .mesh ([
168+ transmiter_back .transform (rotate (i * 2 * pi / transmiter_amount , Z ))
169+ for i in range (transmiter_amount ) ]))
170+ exterior = union (head , exterior_shell )
171+
172+ interior .mergeclose ()
173+ part = intersection (interior , exterior ).finish ()
174+
175+ # part decomposition of the shell
176+ split = revolution (2 * pi , Axis (O ,Z ), Wire ([
177+ a + 2 * neighscrew * X - 2 * shell_thickness * Z ,
178+ project (a , Z ) + bearing_radius * X + 2 * shell_thickness * X - 2 * shell_thickness * Z ,
179+ project (a , Z ) + bearing_radius * X - mount_thickness * Z ,
180+ project (a , Z ) + bearing_radius * X - mount_thickness * Z - shell_thickness * (X + Z ),
181+ ]).segmented ()).finish ()
182+ part_top = intersection (part , split )
183+ part_bot = intersection (part , split .flip ())
184+
185+
186+ # annotations
187+ transmiters [0 ]['bearing' ]['annotations' ] = [
188+ note_radius (transmiter ['bearing' ]['part' ].group (1 )),
189+ note_distance_planes (* transmiter ['bearing' ]['part' ].group (2 ).islands ()),
190+ ]
191+ output1 ['bearing' ]['annotations' ] = [
192+ note_radius (output1 ['bearing' ]['part' ].group (2 )),
193+ note_radius (output1 ['bearing' ]['part' ].group (9 )),
194+ note_distance_planes (output1 ['bearing' ]['part' ].group (0 ), output1 ['bearing' ]['part' ].group (3 )),
195+ ]
196+ annotations = [
197+ note_distance (O , a , project = X , offset = 15 * Z ),
198+ ]
199+
200+ show ([
201+ part_top , part_bot ,
202+ output1 , output2 , transmiters ,
203+ bolts ,
204+ ])
0 commit comments