-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshapeokoboxtop.py
63 lines (52 loc) · 1.76 KB
/
shapeokoboxtop.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
import cadquery as cq
from shapeokoboxdefs import *
centerXY = (True, True, False)
def square_screwpost_body(d, h, r):
return (cq.Workplane()
.box(d, d, h, centered=centerXY)
.edges("|Z").fillet(r)
)
screwpost_d = 8
screwpost = square_screwpost_body(screwpost_d, height/2-th, 2)
# make shell
shell = (cq.Workplane("XY")
.box(width, length, height/2, centered=centerXY)
.faces(">Z")
.shell(-th)
# round edges
.edges("<Z or |Z").fillet(fillet_r)
)
shell.faces("<Z").workplane(centerOption="CenterOfMass",
invert=True).tag("bottom")
# distribute screwposts and holes
screwposts = (shell
.workplaneFromTagged("bottom")
.transformed(offset=(0, 0, th))
.rect(width - 1.2*screwpost_d, length - 1.2*screwpost_d, forConstruction=True)
.vertices()
.eachpoint(lambda loc: screwpost.val().moved(loc), True)
)
result = shell.union(screwposts)
result = (result
.workplaneFromTagged("bottom")
.transformed(offset=(0, 0, height/2))
.rect(width - 1.2*screwpost_d, length - 1.2*screwpost_d, forConstruction=True)
.vertices()
.circle(1.8/2)
.cutThruAll()
)
result = (result
.workplaneFromTagged("bottom")
.transformed(offset=(0, 0, 0))
.rect(width - 1.2*screwpost_d, length - 1.2*screwpost_d, forConstruction=True)
.vertices()
.circle(3.5/2)
.cutBlind(4)
)
result = (result
.workplaneFromTagged("bottom")
.transformed(offset=(0, 0, height/2), rotate=(90, 0, 0))
.circle(2.45)
.cutThruAll()
)
show_object(result)