-
Notifications
You must be signed in to change notification settings - Fork 13
/
3D_Printer_Extruder_Support.py
215 lines (163 loc) · 7.96 KB
/
3D_Printer_Extruder_Support.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
# 3d printer for mounting hotend to X-carriage inspired by the P3steel Toolson
# edition - http://www.thingiverse.com/thing:1054909
import cadquery as cq
def move_to_center(cqObject, shape):
'''
Moves the origin of the current Workplane to the center of a given
geometry object
'''
# transform to workplane local coordinates
shape_center = shape.Center().sub(cqObject.plane.origin)
# project onto plane using dot product
x_offset = shape_center.dot(cqObject.plane.xDir)
y_offset = shape_center.dot(cqObject.plane.yDir)
return cqObject.center(x_offset, y_offset)
# Parameter definitions
main_plate_size_y = 67 # size of the main plate in y direction
main_plate_size_x = 50. # size of the main plate in x direction
main_plate_thickness = 10. # thickness of the main plate
wing_size_x = 10. # size of the side wing supporting the bridge in x direction
wing_size_y = 10. # size of the side wing supporting the bridge in y direction
bridge_depth = 35. # depth of the bridge
support_depth = 18. # depth of the bridge support
cutout_depth = 15. # depth of the hotend cutout
cutout_rad = 8. # radius of the cutout (cf groove mount sizes of E3D hotends)
cutout_offset = 2. # delta radius of the second cutout (cf groove mount sizes of E3D hotends)
extruder_hole_spacing = 50. # spacing of the extruder mounting holes (Wade's geared extruder)
m4_predrill = 3.7 # hole diameter for m4 tapping
m3_predrill = 2.5 # hole diameter for m3 tapping
m3_cbore = 5. # counterbore size for m3 socket screw
mounting_hole_spacing = 28. # spacing of the mounting holes for attaching to x-carriage
aux_hole_depth = 6. # depth of the auxiliary holes at the sides of the object
aux_hole_spacing = 5. # spacing of the auxiliary holes within a group
aux_hole_N = 2 # number of the auxiliary hole per group
# make the main plate
res = cq.Workplane('front').box(main_plate_size_x,
main_plate_size_y,
main_plate_thickness)
def add_wing(obj, sign=1):
'''
Adds a wing to the main plate, defined to keep the code DRY
'''
obj = obj.workplane()\
.hLine(sign*wing_size_x)\
.vLine(-wing_size_y)\
.line(-sign*wing_size_x, -2*wing_size_y)\
.close().extrude(main_plate_thickness)
return obj
# add wings
# add right wing
res = res.faces('<Z').vertices('>XY')
res = add_wing(res)
# store sides of the plate for further reuse, their area is used later on to calculate "optimum" spacing of the aux hole groups
face_right = res.faces('>X[1]').val()
face_left = res.faces('>X[-2]').val()
# add left wing
res = res.faces('<Z').vertices('>Y').vertices('<X')
res = add_wing(res, -1)
# make the bridge for extruder mounting
wp = res.faces('>Z') # select top face
e = wp.edges('>Y') # select most extreme edge in Y direction
bridge_length = e.val().Length() # the width of the bridge equals to the length of the selected edge
# draw the bridge x-section and extrude
res = e.vertices('<X'). \
workplane(). \
hLine(bridge_length). \
vLine(-10). \
hLine(-bridge_length). \
close().extrude(bridge_depth)
faces = res.faces('>Z[1]') # take all faces in Z direction and select the middle one; note the new selector syntax
edge = faces.edges('>Y') # select the top edge of this face...
res = move_to_center(faces.workplane(), edge.val()).\
transformed(rotate=(0, 90, 0)) # ...and make a workplane that is centered in this edge and oriented along X direction
res = res.vLine(-support_depth).\
line(-support_depth, support_depth).\
close() # draw a triangle
res = res.extrude(main_plate_size_x/2, both=True, clean=True) # extrude the triangle, now the bridge has a nice support making it much more stiff
# Start cutting out a slot for hotend mounting
face = res.faces('>Y') # select the most extreme face in Y direction, i.e. top of the "bridge"
res = move_to_center(face.workplane(), face.edges('>Z').val()) # shift the workplane to the center of the most extreme edge of the bridge
def make_slot(obj, depth=None):
'''
Utility function that makes a slot for hotend mounting
'''
obj = obj.moveTo(cutout_rad, -cutout_depth).\
threePointArc((0, -cutout_depth-cutout_rad),
(-cutout_rad, -cutout_depth)).\
vLineTo(0).hLineTo(cutout_rad).close()
if depth is None:
obj = obj.cutThruAll()
else:
obj = obj.cutBlind(depth)
return obj
res = make_slot(res, None) # make the smaller slot
cutout_rad += cutout_offset # increase the cutout radius...
res = make_slot(res.end().end(), -main_plate_thickness/2) # ...and make a slightly larger slot
res = res.end().moveTo(0, 0) \
.pushPoints([(-extruder_hole_spacing/2, -cutout_depth), (extruder_hole_spacing/2, -cutout_depth)]) \
.hole(m4_predrill) # add extruder mounting holes at the top of the bridge
# make additional slot in the bridge support which allows the hotend's radiator to fit
cutout_rad += 3*cutout_offset
res = make_slot(res.end().moveTo(0, 0).workplane(offset=-main_plate_thickness))
# add reinforcement holes
cutout_rad -= 2*cutout_offset
res = res.faces('>Z').workplane().\
pushPoints([(-cutout_rad, -main_plate_thickness/4),
(cutout_rad, -main_plate_thickness/4)]).\
hole(m3_predrill)
# add aux holes on the front face
res = res.moveTo(-main_plate_size_x/2., 0).workplane().rarray(aux_hole_spacing, 1, aux_hole_N, 1) \
.hole(m3_predrill, depth=aux_hole_depth)
res = res.moveTo(main_plate_size_x, 0).workplane().rarray(aux_hole_spacing, 1, aux_hole_N, 1) \
.hole(m3_predrill, depth=aux_hole_depth)
# make a hexagonal cutout
res = res.faces('>Z[1]')
res = res.workplane(offset=bridge_depth). \
transformed(rotate=(0, 0, 90)). \
polygon(6, 30).cutThruAll()
# make 4 mounting holes with cbores
res = res.end().moveTo(0, 0). \
rect(mounting_hole_spacing,
mounting_hole_spacing, forConstruction=True)
res = res.vertices(). \
cboreHole(m3_predrill,
m3_cbore,
bridge_depth+m3_cbore/2)
# make cutout and holes for mounting of the fan
res = res.transformed(rotate=(0, 0, 45)). \
rect(35, 35).cutBlind(-bridge_depth).end(). \
rect(25, 25, forConstruction=True).vertices().hole(m3_predrill)
def make_aux_holes(workplane, holes_span, N_hole_groups=3):
'''
Utility function for creation of auxiliary mouting holes at the sides of the object
'''
res = workplane.moveTo(-holes_span/2).workplane().rarray(aux_hole_spacing, 1, aux_hole_N, 1) \
.hole(m3_predrill, depth=aux_hole_depth)
for i in range(N_hole_groups-1):
res = res.moveTo(holes_span/(N_hole_groups-1.)).workplane().rarray(aux_hole_spacing, 1, aux_hole_N, 1) \
.hole(m3_predrill, depth=aux_hole_depth)
return res
# make aux holes at the bottom
res = res.faces('<Y').workplane()
res = make_aux_holes(res, main_plate_size_x*2/3., 3)
# make aux holes at the side (@overhang)
res = res.faces('<X').workplane().transformed((90, 0, 0))
res = make_aux_holes(res, main_plate_size_x*2/3., 3)
res = res.faces('>X').workplane().transformed((90, 0, 0))
res = make_aux_holes(res, main_plate_size_x*2/3., 3)
# make aux holes at the side (@main plate)
res = res.faces('|X').edges('<Y').edges('>X')
res = res.workplane()
res = move_to_center(res, face_right)
res = res.transformed((90, 0, 0))
hole_sep = 0.5*face_right.Area()/main_plate_thickness
res = make_aux_holes(res, hole_sep, 2)
# make aux holes at the side (@main plate)
res = res.faces('|X').edges('<Y').edges('<X')
res = res.workplane()
res = move_to_center(res, face_left)
res = res.transformed((0, 180, 0))
hole_sep = 0.5*face_right.Area()/main_plate_thickness
res = make_aux_holes(res, hole_sep, 2)
# show the result
show_object(res)