From 06beec10d25d8538db1aa58e7079b460acec496d Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Sat, 13 Jan 2024 10:42:19 +0100 Subject: [PATCH] AirPurifier: Add split_frames param to allow saving material --- boxes/generators/airpurifier.py | 77 ++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/boxes/generators/airpurifier.py b/boxes/generators/airpurifier.py index f74f8343..70faf46b 100644 --- a/boxes/generators/airpurifier.py +++ b/boxes/generators/airpurifier.py @@ -24,18 +24,19 @@ class AirPurifier(Boxes): description = """Still untested""" fan_holes = { - 40: 32.5, - 60: 50, - 80: 71.5, - 92: 82.5, - 120: 105, - 140: 125, + 40.: 32.5, + 60.: 50, + 80.: 71.5, + 92.: 82.5, + 120.: 105, + 140.: 125, } def __init__(self) -> None: Boxes.__init__(self) self.addSettingsArgs(edges.FingerJointSettings) + self.addSettingsArgs(edges.DoveTailSettings, size=2.0, depth=1) self.buildArgParser(x=498., y=496.) @@ -52,7 +53,10 @@ def __init__(self) -> None: self.argparser.add_argument( "--filters", action="store", type=int, default=2, choices=(1, 2), - help="") + help="Filters on both sides or only one") + self.argparser.add_argument( + "--split_frames", action="store", type=BoolArg(), default=True, + help="Split frame pieces into four thin rectangles to save material") self.argparser.add_argument( "--fans_left", action="store", type=int, default=-1, help="number of fans on the left side (-1 for maximal number)") @@ -72,12 +76,20 @@ def __init__(self) -> None: def fanCB(self, n, h, l, fingerHoles=True): fh = self.filter_height t = self.thickness + r = self.rim def cb(): if fingerHoles: - self.fingerHolesAt(0, fh + t/2, l, 0) + heights = [fh + t/2] if self.filters > 1: - self.fingerHolesAt(0, h- fh - t/2, l, 0) + heights.append(h - fh - t/2) + for h_ in heights: + if self.split_frames: + self.fingerHolesAt(0, h_, r, 0) + self.fingerHolesAt(r, h_, l-2*r, 0) + self.fingerHolesAt(l-r, h_, r, 0) + else: + self.fingerHolesAt(0, h_, l, 0) max_n = int((l-20) // (self.fan_diameter + 10)) if n == -1: @@ -107,35 +119,50 @@ def cb(): def render(self): x, y, d = self.x, self.y, self.fan_diameter t = self.thickness + r = self.rim y = self.y = y - t # shorten by one thickness as we use the wall space fh = self.filter_height h = d + 2 + self.filters * (fh + t) - if self.filters==2: - edge = edges.CompoundEdge(self, "EFE", (fh + t, d+2, fh + t)) - else: - edge = edges.CompoundEdge(self, "FE", (d+2, fh + t)) self.rectangularWall(x, d, "ffff", callback=[ self.fanCB(self.fans_top, d, x, False)], label="top", move="up") self.rectangularWall(x, h, "ffff", callback=[ self.fanCB(self.fans_bottom, h, x)], label="bottom", move="up") + be = te = edges.CompoundEdge(self, "fff", (r, y - 2*r, r)) \ + if self.split_frames else "f" + + if self.filters==2: + le = edges.CompoundEdge(self, "EFE", (fh + t, d+2, fh + t)) + else: + le = edges.CompoundEdge(self, "FE", (d+2, fh + t)) + te = "f" + for fans in (self.fans_left, self.fans_right): - self.rectangularWall(y, h, ["f", "h", "f", edge], + self.rectangularWall(y, h, [be, "h", te, le], callback=[self.fanCB(fans, h, y)], move="up") - r = self.rim - self.rectangularWall(x, y, "Ehhh", callback=[ - lambda:self.rectangularHole(x/2, y/2, x - r, y - r, r=10)], move="up") - self.rectangularWall(x, y, "Ffff", callback=[ - lambda:self.rectangularHole(x/2, y/2, x - r, y - r, r=10)], move="up") - if self.filters==2: - self.rectangularWall(x, y, "Ffff", callback=[ - lambda:self.rectangularHole(x/2, y/2, x - r, y - r, r=10)], move="up") - self.rectangularWall(x, y, "Ehhh", callback=[ - lambda:self.rectangularHole(x/2, y/2, x - r, y - r, r=10)], move="up") + + if self.split_frames: + e = edges.CompoundEdge(self, "DeD", (r, x - 2*r, r)) + for _ in range(self.filters): + self.rectangularWall(x, r, ["E", "h", e, "h"], move="up") + self.rectangularWall(y - 2*r, r, "hded", move="up") + self.rectangularWall(y - 2*r, r, "hded", move="up") + self.rectangularWall(x, r, [e, "h", "h", "h"], move="up") + + self.rectangularWall(x, r, ["F", "f", e, "f"], move="up") + self.rectangularWall(y - 2*r, r, "fded", move="up") + self.rectangularWall(y - 2*r, r, "fded", move="up") + self.rectangularWall(x, r, [e, "f", "f", "f"], move="up") else: - self.rectangularWall(x, y, "Ehhh", move="up") + for _ in range(self.filters): + self.rectangularWall(x, y, "Ffff", callback=[ + lambda:self.rectangularHole(x/2, y/2, x - r, y - r, r=10)], move="up") + self.rectangularWall(x, y, "Ehhh", callback=[ + lambda:self.rectangularHole(x/2, y/2, x - r, y - r, r=10)], move="up") + if self.filters==1: + self.rectangularWall(x, y, "hhhh", move="up")