-
Notifications
You must be signed in to change notification settings - Fork 1
/
vac_brack.py
57 lines (55 loc) · 1.56 KB
/
vac_brack.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
import importlib
import cadquery as cq
import dims
importlib.reload(dims)
bracket = (
cq
.Workplane("XZ")
.moveTo(dims.vac_brack.x_centre, 0)
.box(
dims.vac_brack.x
, dims.vac_brack.z
, dims.vac_brack.y
, centered=(True, True, False)
)
.faces("<Y")
.workplane(centerOption='ProjectedOrigin', origin=(0, 0, 0))
.pushPoints([(x, 0) for x in dims.vac_brack.holes])
.cboreHole(
dims.vac_brack.hole.diam
, dims.vac_brack.hole.cbore_diam
, dims.vac_brack.hole.cbore_depth
)
)
cutters = []
for pos in dims.magnet.positions:
selector = ">Z" if pos[1] >= 0 else "<Z"
cut_depth = dims.vac_brack.z / 2 - max([y for _, y in dims.magnet.positions])
temp = (
bracket
.faces(selector)
.workplane(
centerOption='ProjectedOrigin'
, origin=(
pos[0]
, -dims.vac_brack.y + dims.magnet.wall_thick + dims.magnet.slot.thick / 2
, 0
)
)
)
assert abs(cut_depth) > 1e-2, "near zero cut depth, you've fucked up"
cutters.append(
temp
.rect(dims.magnet.slot.width, dims.magnet.slot.thick, centered=True)
.extrude(-cut_depth, combine=False)
)
cutters.append(
temp
.workplane(offset=-cut_depth)
.move(0, -dims.magnet.slot.thick / 2)
.rect(dims.magnet.slot.width / 2, dims.magnet.slot.thick, centered=False)
.revolve(axisEnd=(0, 1), combine=False)
)
for cutter in cutters:
bracket = bracket.cut(cutter)
del cutter