-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvac.py
194 lines (181 loc) · 6.35 KB
/
vac.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
"""
3d printed part, has the vacuum hose inserted and duct taped to it, attached
with magnets to vac_brack, and has a tube going up to vac_hangar.
Origin will be bottom center of the spindle's collet nut.
"""
import importlib
import math
import cadquery as cq
import dims
import vac_helpers as vh
importlib.reload(dims)
importlib.reload(vh)
# make top wire
# make bottom wire
# top face is cq.Face.makeFromWire(top_wire)
# bottom face is cq.Face.makeFromWire(bottom_wire)
# vertical face is cq.Face.makeRuledSurface(top_wire, bottom_wire)
# then make shell, solid, cut
# some dimensions:
inner_port_major_rad = dims.vac.inner_rad + dims.vac.wall_thick
outer_port_major_rad = inner_port_major_rad + dims.vac.port.rad * 2
brush_slot_major_radius = (
outer_port_major_rad + dims.vac.wall_thick
+ 15 + dims.vac.brush.slot_width / 2
)
body_major_radius = (
brush_slot_major_radius + dims.vac.brush.slot_width / 2
+ dims.vac.wall_thick
)
# the width of material between the edge of the vacuum port and outer edge
vac_port_to_body_outer = (body_major_radius - outer_port_major_rad)
kidney_wire, hose_wire = vh.kidney_and_circle_wires(
dims.vac.hose.id / 2,
cq.Vector(dims.vac.hose.plane.origin),
inner_port_major_rad,
outer_port_major_rad
)
vert_face = cq.Face.makeRuledSurface(kidney_wire, hose_wire)
bottom_face = cq.Face.makeFromWires(kidney_wire)
rev_hose_wire = cq.Edge(hose_wire.wrapped.Reversed())
top_face = cq.Face.makeFromWires(rev_hose_wire)
shell = cq.Shell.makeShell([bottom_face, vert_face, top_face])
solid = cq.Solid.makeSolid(shell)
vacuum_path = cq.Workplane(solid)
part = (
cq
.Workplane()
.moveTo(dims.vac.mount_face.x_max, dims.vac.mount_face.y)
.hLineTo(dims.vac.mount_face.x_min)
.vLineTo(dims.vac.inner_rad)
.hLineTo(0)
.tangentArcPoint((0, -dims.vac.inner_rad * 2), relative=True)
# now I need a tangentArcPoint out to the outer edge, which takes into account the slot for the brush.
)
# y centre of the circle
yc = -inner_port_major_rad - dims.vac.port.rad
# radius of outer edge
r_outer_initial = dims.vac.port.rad + dims.vac.wall_thick + dims.vac.brush.slot_width + dims.vac.wall_thick
r_outer = dims.vac.port.rad + vac_port_to_body_outer
# to get to that radius, the line must extend horizontally until
x_start = math.sqrt(r_outer ** 2 - (dims.vac.port.rad + dims.vac.wall_thick) ** 2)
# inner radius of the kidney shape
rk_inner = abs(yc) - dims.vac.port.rad - dims.vac.wall_thick
rk_outer = rk_inner + dims.vac.port.rad + r_outer
part = (
part
.spline(
[(-r_outer_initial - 5, yc)]
, tangents=[(-1, 0), (0, -1)]
, includeCurrent=True
)
# .radiusArc((0, -body_major_radius), -r_outer)
.spline(
[(0, -body_major_radius)],
tangents=[(0, -1), (1, 0)],
includeCurrent=True,
)
.radiusArc((body_major_radius, 0), -body_major_radius)
.spline(
[(dims.vac.mount_face.x_max, dims.vac.mount_face.y)]
, tangents=[(0, 1), (-1, 0)]
, includeCurrent=True
)
.close()
.extrude(dims.vac.z)
.tag('base')
.faces(">Y")
.workplane(centerOption='ProjectedOrigin', origin=(0, 0, dims.vac.z / 2))
.pushPoints([(-pos, 0) for pos in dims.vac_brack.holes])
.circle(dims.vac_brack.hole.cbore_diam / 2 - 0.1)
.extrude(dims.vac_brack.hole.cbore_depth - 2, taper=10)
.faces(">Z", tag='base')
.workplane(centerOption='ProjectedOrigin', origin=(0, 0, 0))
.hole(dims.spindle.bearing_cap.diam + 2, dims.spindle.bearing_cap.height + 2)
)
kidney_wire, hose_wire = vh.kidney_and_circle_wires(
dims.vac.chimney.main_od / 2 + dims.vac.wall_thick,
dims.vac.hose.plane.origin,
rk_inner,
body_major_radius
)
vert_face = cq.Face.makeRuledSurface(kidney_wire, hose_wire)
bottom_face = cq.Face.makeFromWires(kidney_wire)
reversed_hose_wire = cq.Edge(hose_wire.wrapped.Reversed())
top_face = cq.Face.makeFromWires(reversed_hose_wire)
shell = cq.Shell.makeShell([bottom_face, vert_face, top_face])
vacuum_port_walls = cq.Solid.makeSolid(shell)
upper_vac = (
cq.Workplane('XY', origin=dims.vac.hose.plane.origin)
.circle(dims.vac.chimney.main_od / 2 + dims.vac.wall_thick)
.extrude(dims.vac.wall_thick)
.tag('base')
.faces('>Z')
.workplane()
.hole(dims.vac.chimney.main_od, dims.vac.wall_thick)
.faces('>Z', tag='base')
.workplane()
.hole(dims.vac.hose.id)
.union(vacuum_port_walls, clean=False, tol=0.1)
)
brush_offset = dims.vac.wall_thick + dims.vac.brush.slot_width / 2
r_brush_to_port = dims.vac.port.rad + brush_offset
brush_slot_path = (
cq
.Workplane()
.moveTo(dims.vac.mount_face.x_min, r_brush_to_port)
.hLineTo(abs(yc))
.spline(
[(brush_slot_major_radius, 0)],
tangents=[(1, 0), (0, -1)],
includeCurrent=True,
)
.tangentArcPoint((0, -brush_slot_major_radius), relative=False)
.spline(
[(-r_brush_to_port, yc + 5)],
tangents=[(-1, 0), (0, 1)],
includeCurrent=True
)
)
brush_slot = (
cq
.Workplane('XZ', origin=brush_slot_path.val().endPoint())
.center(0, dims.vac.brush.slot_depth / 2)
.moveTo(-dims.vac.brush.slot_width / 2, -dims.vac.brush.slot_depth / 2)
.hLine(dims.vac.brush.slot_width)
.vLine(dims.vac.brush.slot_depth - dims.vac.brush.slot_width)
.tangentArcPoint((-dims.vac.brush.slot_width, 0), relative=True)
.close()
.sweep(brush_slot_path)
)
part = part.union(upper_vac).cut(vacuum_path).cut(brush_slot)
cutters = []
for pos in dims.magnet.positions:
selector = ">Z" if pos[1] >= 0 else "<Z"
inverse_selector = "<Z" if pos[1] >= 0 else ">Z"
cut_depth = dims.vac.z / 2 - max([y for _, y in dims.magnet.positions])
temp = (
part
.faces(selector, tag='base')
.workplane(
centerOption='ProjectedOrigin',
origin=(
0,
dims.vac.mount_face.y - dims.magnet.wall_thick - dims.magnet.slot.thick / 2,
0
)
)
.move(pos[0], 0)
.rect(dims.magnet.slot.width, dims.magnet.slot.thick, centered=True)
.extrude(-cut_depth, combine=False)
.faces(inverse_selector)
.workplane()
.center(0, -dims.magnet.slot.thick / 2)
.rect(dims.magnet.slot.width / 2, dims.magnet.slot.thick, centered=False)
.revolve(axisEnd=(0, 1))
)
cutters.append(temp)
del temp
for cutter in cutters:
part = part.cut(cutter)
del cutter