55CU = 18.415
66CAP_TOP = 12.7
77
8+ CAP_RADIUS = 1.5
9+
10+
811def sa_indent (angle , height , uwidth ):
912 DISH_RADIUS = 55
10- DIP = 0.738 + 0.001
13+ DIP = 0.738 + 0.1
1114
1215 rwidth = UNIT * uwidth - (UNIT - CAP_TOP )
1316
@@ -22,25 +25,21 @@ def sa_indent(angle, height, uwidth):
2225 .mirror (mirrorPlane = "YZ" , union = True )
2326
2427def sa_profile_loft (angle , uwidth , height ):
25- LOFT = 2
28+ LOFT = 1
2629
2730 rwidth = UNIT * uwidth - (UNIT - CU )
2831 rwidth_cap = UNIT * uwidth - (UNIT - CAP_TOP )
2932
30- cronk = cq .Workplane ("XY" ).rect (rwidth , CU )
31- cronk = cronk .workplane (offset = LOFT ).transformed (rotate = (0 , 0 , 0 )).rect (rwidth - 0.1 , CU * 0.99 )
32- cronk = cronk .add (cq .Workplane ("XY" )).transformed (offset = (0 , 0 , height - LOFT ), rotate = (angle , 0 , 0 )).rect (rwidth_cap , CAP_TOP )
33- cronk = cronk .loft ()
34-
3533 dish = sa_indent (angle , height , uwidth )
36- cronk = cronk .cut (dish )
3734
38- cronk = cronk .faces ("<Z" ).shell (- 1.5 , kind = 'arc' )
39- cronk = cronk .edges ("not <Z" ).fillet (1 )
35+ bottom = cq .Workplane ("XY" ).rect (rwidth - 1 , CU - 1 ).offset2D (0.5 )
36+ support = cq .Workplane ("XY" ).transformed (offset = (0 , 0 , LOFT )).rect (rwidth - 1.1 , CU - 1.1 ).offset2D (0.5 )
37+ top = cq .Workplane ("XY" ).transformed (offset = (0 , 0 , height ), rotate = (angle , 0 , 0 )).rect (rwidth_cap - 2 * CAP_RADIUS , CAP_TOP - 2 * CAP_RADIUS ).offset2D (1.5 ).consolidateWires ()
4038
41- #cronk = cq.Workplane("XY").box(UNIT, UNIT, UNIT, centered = [True, True, False]).cut(dish).edges().fillet(2)
39+ keycap = cq .Workplane ("XY" ).add (bottom ).add (support ).add (top ).toPending ().loft ().cut (dish )
40+ keycap = keycap .edges (cq .selectors .BoxSelector ((- rwidth / 2 , - CU / 2 , height - 2 ), (rwidth / 2 , CU / 2 , height + 5 ))).fillet (0.25 )
4241
43- return cronk
42+ return keycap
4443
4544
4645def sa_profile (row , uwidth ):
@@ -77,14 +76,15 @@ def draw_keys(keys):
7776 coff = 0
7877
7978 for key in row :
80- kobj = sa_profile (key [0 ], key [1 ]).translate ([(coff + key [1 ]/ 2 ) * UNIT , - roff * UNIT , 0 ])#.fillet(0.0001)
79+ kobj = sa_profile (key [0 ], key [1 ]).translate ([(coff + key [1 ]/ 2 ) * UNIT , - roff * UNIT , 0 ])
80+ fname = "build/SA/%1dR%3dU.step" % (key [0 ], key [1 ]* 100 )
81+ cq .exporters .export (kobj , fname )
8182 show_object (kobj , "Key (%.2f x %d)" % (coff , roff ))
8283 coff += key [1 ]
8384
8485 roff += 1
8586
8687
8788draw_keys (keys )
88- #draw_keys([[[5, 6.5 ]]])
89+ #draw_keys([[[3, 1.25 ]]])
8990
90- #show_object(sa_profile(3, 1.25))
0 commit comments