-
Notifications
You must be signed in to change notification settings - Fork 1
/
chimney.py
221 lines (211 loc) · 6.61 KB
/
chimney.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import cadquery as cq
import dims
import importlib
importlib.reload(dims)
# this chimney should be a sweep over a set of profiles. The outer edge should
# be a straight line, the inner edge should curve quite a bit so that it avoids
# the clamp.
# base
# midprofile
# mount-base
# top
profiles = (
cq
.Workplane()
# oh dear god I have to rewrite the .workplane method soon, this is hideous
.tag('0')
# bottom
.center(0, dims.chimney.base.od / 2)
.tag('1')
.circle(dims.chimney.base.od / 2)
# straight section for the lip to be cut into
.extrude(dims.chimney.base.step_z)
# base of the taper
.faces(">Z")
# for some reason the following gets the wrong radius circle!
# .edges()
# .toPending()
.workplane(centerOption='ProjectedOrigin', origin=(0, 0, 0))
.center(0, dims.chimney.base.od / 2)
.tag('2')
.circle(dims.chimney.base.od / 2)
# mid profile for tapering in to clear the bracket
.workplaneFromTagged('0')
.workplane(
centerOption='ProjectedOrigin',
origin=(0, 0, 0),
offset=dims.chimney.midprofile.z
)
.center(0, dims.chimney.midprofile.od / 2)
.tag('3')
.circle(dims.chimney.midprofile.od / 2)
# continue tapering in to the base of the mount
.workplaneFromTagged('0')
.workplane(
centerOption="ProjectedOrigin",
origin=(0, 0, 0),
offset=dims.chimney.mountbase.z
)
.center(0, dims.chimney.mountbase.od / 2)
.tag('4')
.circle(dims.chimney.mountbase.od / 2)
)
path = (
cq
.Workplane('XZ')
.moveTo(0, dims.chimney.base.step_z)
.vLineTo(dims.chimney.mountbase.z)
)
chimney = (
profiles
.sweep(path, multisection=True)
.workplaneFromTagged('0')
.workplane(
centerOption="ProjectedOrigin",
origin=(0, 0, 0),
offset=dims.chimney.mountbase.z
)
.move(0, dims.chimney.mountbase.od / 2)
.circle(dims.chimney.mountbase.od / 2)
.extrude(dims.chimney.top.z - dims.chimney.mountbase.z)
.tag('beforemountface')
)
# mounting face
chimney = (
chimney
.copyWorkplane(
cq.Workplane('YZ', origin=(0, dims.chimney.mountbase.od / 2, dims.chimney.mountface.origin[2]))
)
.transformed(rotate=(0, -45, 0))
.workplane(centerOption='CenterOfMass', offset=-dims.chimney.mountface.width / 2)
.moveTo(dims.chimney.mountface.origin[1], dims.chimney.mountface.height / 2)
.hLineTo(0)
.vLine(-dims.chimney.mountface.height)
.lineTo(dims.chimney.mountface.origin[1], -dims.chimney.mountface.height / 2)
.close()
.extrude(dims.chimney.mountface.width)
.tag('mountbase')
)
for sign in [-1, 1]:
chimney = (
chimney
.faces(">(1, 1, 0)", tag="mountbase")
.workplane(centerOption='CenterOfMass')
.moveTo(
sign * (dims.chimney.mountface.align.hole.diam + dims.vac.wall_thick) / 2,
0
)
.circle(dims.chimney.mountface.align.stub.diam / 2)
.extrude(
dims.chimney.mountface.align.stub.length,
taper=dims.chimney.mountface.align.stub.taper
)
)
# hose socket
chimney = (
chimney
.faces('>Z', tag='beforemountface')
.workplane(centerOption='CenterOfMass')
.circle(dims.chimney.top.od / 2)
.workplane(centerOption='CenterOfMass', offset=dims.chimney.hose.socket.od - dims.chimney.top.od)
.circle(dims.chimney.hose.socket.od / 2)
.loft()
.faces(">Z")
.workplane(centerOption='CenterOfMass')
.circle(dims.chimney.hose.socket.od / 2)
.extrude(dims.vac.wall_thick + dims.chimney.hose.insertion + dims.chimney.hose.tape_width)
.tag('top holes')
.faces(">Z")
.workplane(centerOption='CenterOfMass')
.hole(
dims.chimney.hose.od,
depth=dims.chimney.hose.insertion + dims.chimney.hose.tape_width
)
# .faces(">Z", tag="top holes")
# .workplane()
# .hole(
# dims.chimney.hose.id,
# depth=dims.vac.wall_thick + dims.chimney.hose.insertion + dims.chimney.hose.tape_width
# )
.faces(">Z", tag="top holes")
.workplane(centerOption='CenterOfMass')
.center(dims.chimney.hose.od / 2, 0)
.rect(10, dims.chimney.hose.socket.od * 2)
.cutBlind(-dims.chimney.hose.tape_width)
.faces(">Z", tag="top holes")
.workplane(centerOption='CenterOfMass')
.center(-dims.chimney.hose.od / 2, 0)
.rect(10, dims.chimney.hose.socket.od * 2)
.cutBlind(-dims.chimney.hose.tape_width)
)
cutter = (
chimney
.faces("<Z")
.workplane(centerOption='CenterOfMass')
.circle(dims.chimney.base.od)
.extrude(-dims.chimney.base.step_z, combine=False)
.faces("<Z")
.workplane(centerOption='CenterOfMass')
.hole(dims.chimney.base.step_diam - 0.1)
)
chimney = chimney.cut(cutter)
del cutter
chimney_top = chimney.findSolid().BoundingBox().zmax
vac_path = (
cq.Workplane()
.copyWorkplane(chimney.workplaneFromTagged('2'))
.circle(dims.chimney.base.id / 2)
.copyWorkplane(chimney.workplaneFromTagged('3'))
.circle(dims.chimney.midprofile.id / 2)
.copyWorkplane(chimney.workplaneFromTagged('4'))
.circle(dims.chimney.mountbase.id / 2)
.sweep(path, multisection=True)
.faces("<Z")
.workplane(centerOption='CenterOfMass')
.circle(dims.chimney.base.id / 2)
.extrude(dims.chimney.base.step_z)
.faces(">Z")
.workplane(centerOption='CenterOfMass')
.circle(dims.chimney.top.id / 2)
.extrude(chimney_top - dims.chimney.mountbase.z)
)
chimney = chimney.cut(vac_path)
del vac_path
# magnets in the mounting face
cutters = []
# TODO: bottom face can't be selected, so rewrite this to locate a large cutter
# at magnet position
magnet_cutter = (
cq
.Workplane('XZ', origin=(0, 0, 0))
.moveTo(dims.magnet.slot.width / 2, dims.magnet.diam)
.vLineTo(0)
.tangentArcPoint((-dims.magnet.slot.width / 2, 0), relative=False)
.vLineTo(dims.magnet.diam)
.close()
.extrude(dims.magnet.slot.thick)
)
ys = [pos[1] for pos in dims.chimney.mountface.magnet.position]
y_mid = (min(ys) + max(ys)) / 2
faces = chimney.faces(">(1, 1, 0)", tag="mountbase").vals()
shell = cq.Shell.makeShell(faces)
mount_origin = shell.Center()
plane = (
chimney
.faces(">(1, 1, 0)", tag="mountbase")
.workplane(centerOption='CenterOfMass')
.plane
)
for pos in dims.chimney.mountface.magnet.position:
angle = 180 if (pos[1] < y_mid) else 0
final_pos = plane.toWorldCoords((pos[0], pos[1], -dims.magnet.wall_thick))
cutters.append(
magnet_cutter
.rotate((0, 0, 0), (0, 0, 1), -45)
.rotate((0, 0, 0), (1, 1, 0), angle)
.translate(final_pos)
)
del magnet_cutter
for cutter in cutters:
chimney = chimney.cut(cutter)
del cutter