-
Notifications
You must be signed in to change notification settings - Fork 0
/
saurdisp.py
137 lines (120 loc) · 3.48 KB
/
saurdisp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import cadquery as cq
import math
# shell thickness
th = 3
# shell fillet radius
fillet_r = 5
disp_hole_w = 71
disp_hole_h = 51
disp_w = 80
disp_h = 57
disp_h_cc_x = 85
disp_h_cc_y = 50.8
centerXY = (True, True, False)
bot_depth = 55
top_depth = 25
height = 70
width = 105
# make shell
result = (cq.Workplane("XZ")
.hLine(bot_depth)
.vLine(height)
.hLine(-top_depth)
.lineTo(0, 0)
.close()
.extrude(width)
.faces("<Z")
.shell(-th)
# round back edges
.edges("|Z").fillet(fillet_r)
# round top
.faces(">Z")
.edges().fillet(fillet_r)
# round front edges
.edges('|(30, 0, 70)').fillet(fillet_r)
)
# workplane aligned with front face
angle = math.degrees(math.atan(height/(bot_depth-top_depth)))
(result
.faces("<Z")
.workplane(centerOption="CenterOfMass", invert=True)
.transformed(offset=(-13, 0, 32), rotate=(0, -angle, 0))
.tag("front")
)
# for debugging
#result = result.workplaneFromTagged("front").box(50, 50, 10, centered=centerXY)
disp_y_offset = 3
# hole for display
result = (result
.workplaneFromTagged("front")
.transformed(offset=(disp_y_offset, 0, th))
.rect(disp_hole_h, disp_hole_w)
.cutBlind(-10)
)
# recess for display
result = (result
.workplaneFromTagged("front")
.transformed(offset=(disp_y_offset-1.5, 0, -5))
.rect(disp_h, disp_w)
.cutBlind(th)
)
# mount
mount_th = 5
mount_h = 12
mount_w = width - 2*th
mount_d = bot_depth - 13
mount = (cq.Workplane("XY")
.transformed(offset=(th, -width+(width-mount_w)/2, -(mount_h-th)))
.box(mount_d, mount_w, mount_h, centered=False)
.faces("<Z or >Z")
.shell(-mount_th)
)
result = (result + mount)
# screwposts for display
def make_disp_screwpost(o, xs, ys):
ovec1 = (disp_y_offset+xs*disp_h_cc_y/2, ys*disp_h_cc_x/2, -2)
ovec2 = (disp_y_offset+xs*disp_h_cc_y/2, ys*disp_h_cc_x/2, -th)
ovec3 = (disp_y_offset+xs*disp_h_cc_y/2, ys*disp_h_cc_x/2, -10)
return (o
# stud
.workplaneFromTagged("front")
.transformed(offset=ovec1)
.circle(3)
.extrude(-3.5)
# screw hole
.workplaneFromTagged("front")
.transformed(offset=ovec2)
.circle(1.25)
.cutBlind(-10)
# screwdriver hole
.workplaneFromTagged("front")
.transformed(offset=ovec3)
.circle(3.25)
.cutBlind(-100)
)
result = make_disp_screwpost(result, -1, -1)
result = make_disp_screwpost(result, -1, 1)
result = make_disp_screwpost(result, 1, -1)
result = make_disp_screwpost(result, 1, 1)
# slots
def make_slot(xo):
groove_offset = -1
if xo > 0:
groove_offset = 1
return (cq.Workplane("XY")
.transformed(offset=(bot_depth-7.5, -5/2 - xo*(width-5), 0))
.box(8, 5, height-fillet_r, centered=centerXY)
.transformed(offset=(0, groove_offset, height-fillet_r))
.rect(3, 3)
.cutBlind(-height)
)
result = result + make_slot(0)
result = result + make_slot(1)
# back cutout
cutout_w = width - 2* fillet_r
cutout = (cq.Workplane("ZY")
.transformed(offset=(0, -cutout_w-(width-cutout_w)/2, -bot_depth-5))
.box(height - fillet_r, cutout_w, 10, centered=False)
)
result = (result - cutout)
show_object(result)