Add flangedWall() and use it in the ElectronicsBox
This commit is contained in:
parent
b0bef745b2
commit
6ef43a8f48
|
@ -1539,6 +1539,58 @@ class Boxes:
|
|||
|
||||
self.move(overallwidth, overallheight, move)
|
||||
|
||||
def flangedWall(self, x, y, edges="FFFF", flanges=None, r=0.0,
|
||||
callback=None, move=None):
|
||||
"""Rectangular wall with flanges extending the regular size
|
||||
|
||||
This is similar to the rectangularWall but it may extend to either side
|
||||
replacing the F edge with fingerHoles. Use with E and F for edges only.
|
||||
:param x: width
|
||||
:param y: height
|
||||
:param edges: (Default value = "FFFF") bottom, right, top, left
|
||||
:param flanges: (Default value = None) list of width of the flanges
|
||||
:param r: radius of the corners of the flange
|
||||
:param callback: (Default value = None)
|
||||
:param move: (Default value = None)
|
||||
"""
|
||||
|
||||
t = self.thickness
|
||||
|
||||
if not flanges:
|
||||
flanges = [0.0] * 4
|
||||
|
||||
while len(flanges) < 4:
|
||||
flanges.append(0.0)
|
||||
|
||||
flanges = flanges + flanges # double to allow looping around
|
||||
|
||||
tw = x + 2*t + flanges[1] + flanges[3]
|
||||
th = y + 2*t + flanges[0] + flanges[2]
|
||||
|
||||
if self.move(tw, th, move, True):
|
||||
return
|
||||
|
||||
rl = min(r, max(flanges[-1], flanges[0]))
|
||||
self.moveTo(rl)
|
||||
|
||||
for i in range(4):
|
||||
l = y if i % 2 else x
|
||||
|
||||
rl = min(r, max(flanges[i-1], flanges[i]))
|
||||
rr = min(r, max(flanges[i], flanges[i+1]))
|
||||
self.cc(callback, i, x=-rl)
|
||||
if flanges[i]:
|
||||
if edges[i] == "F":
|
||||
self.fingerHolesAt(flanges[i-1]+t-rl, 0.5*t+flanges[i], l,
|
||||
angle=0)
|
||||
self.edge(l+flanges[i-1]+flanges[i+1]+2*t-rl-rr)
|
||||
else:
|
||||
self.edge(flanges[i-1]+t-rl)
|
||||
self.edges.get(edges[i], edges[i])(l)
|
||||
self.edge(flanges[i+1]+t-rr)
|
||||
self.corner(90, rr)
|
||||
self.move(tw, th, move)
|
||||
|
||||
def rectangularTriangle(self, x, y, edges="eee", r=0.0, num=1,
|
||||
bedBolts=None, bedBoltSettings=None,
|
||||
callback=None,
|
||||
|
|
|
@ -54,29 +54,6 @@ class ElectronicsBox(Boxes):
|
|||
t = self.thickness
|
||||
self.fingerHolesAt(0, self.h-1.5*t, self.triangle, 0)
|
||||
self.fingerHolesAt(self.y, self.h-1.5*t, self.triangle, 180)
|
||||
|
||||
def bottom(self, move=None):
|
||||
x, y = self.x, self.y
|
||||
hd = self.holedist
|
||||
t = self.thickness
|
||||
|
||||
if self.move(x+2*t+4*hd, y+2*t, move, True):
|
||||
return
|
||||
|
||||
self.moveTo(hd, 0)
|
||||
self.hole(0, hd, d=self.d3)
|
||||
self.edge(hd+t)
|
||||
self.fingerHolesAt(-0.5*t, t, y, 90)
|
||||
self.edges['F'](x)
|
||||
self.fingerHolesAt(0.5*t, t, y, 90)
|
||||
self.hole(hd+t, hd, d=self.d3)
|
||||
self.polyline(hd+t, (90, hd), y+2*t-2*hd, (90, hd), hd+t)
|
||||
self.hole(-hd-t, hd, d=self.d3)
|
||||
self.edges['F'](x)
|
||||
self.hole(hd+t, hd, d=self.d3)
|
||||
self.polyline(hd+t, (90, hd), y+2*t-2*hd, (90, hd))
|
||||
|
||||
self.move(x+2*t+4*hd, y+2*t, move)
|
||||
|
||||
def render(self):
|
||||
self.open()
|
||||
|
@ -103,7 +80,10 @@ class ElectronicsBox(Boxes):
|
|||
self.rectangularWall(x, y, "FFFF", callback=[
|
||||
lambda:self.hole(hd, hd, d=d3)] *4, move="right")
|
||||
else:
|
||||
self.bottom(move='up')
|
||||
self.flangedWall(x, y, edges="FFFF",
|
||||
flanges=[0.0, 2*hd, 0., 2*hd], r=hd,
|
||||
callback=[
|
||||
lambda:self.hole(hd, hd, d=d2)] * 4, move='up')
|
||||
self.rectangularWall(x, y, callback=[
|
||||
lambda:self.hole(hd, hd, d=d2)] * 4, move='up')
|
||||
|
||||
|
|
Loading…
Reference in New Issue