From bdcad5ee27a8d8521bf80fa673349534a2923ea3 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Sun, 23 May 2021 13:00:52 +0200 Subject: [PATCH] New generator: SlattwallStairs Renders a stair like structure that can house tools like screw drivers if the proper holes or slots are added. --- boxes/generators/slatwallstairs.py | 91 ++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 boxes/generators/slatwallstairs.py diff --git a/boxes/generators/slatwallstairs.py b/boxes/generators/slatwallstairs.py new file mode 100644 index 0000000..734138c --- /dev/null +++ b/boxes/generators/slatwallstairs.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python3 +# Copyright (C) 2013-2019 Florian Festi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from boxes import * + +class SlatwallStairs(Boxes): + """Platforms in different heights e.g. for screw drivers""" + + description = """You are supposed to add holes or slots to the stair tops yourself using Inkscape or another vector drawing or CAD program. + +sh gives height of the stairs from front to back. Note that the overall width and height is bigger than the nominal values as walls and the protrusions are not included in the measurements. +""" + ui_group = "SlatWall" + + def __init__(self): + Boxes.__init__(self) + + self.addSettingsArgs(edges.FingerJointSettings) + self.addSettingsArgs(edges.SlatWallSettings) + + self.buildArgParser(sx="250/3", sy="40*3", sh="30:100:180") + self.argparser.add_argument( + "--braceheight", action="store", type=float, default=30, + help="height of the brace at the bottom back (in mm). Zero for none") + + def yWall(self, move=None): + t = self.thickness + x, sx, y, sy, sh = self.x, self.sx, self.y, self.sy, self.sh + + tw, th = sum(sy), max(sh) + t + + if self.move(tw, th, move, True): + return + + self.polyline(y-t, 90) + self.edges["f"](self.braceheight) + self.step(t) + self.edges["A"](sh[-1] - self.braceheight) + self.corner(90) + for i in range(len(sy)-1, 0, -1): + self.edges["f"](sy[i]) + self.step(sh[i-1]-sh[i]) + self.edges["f"](sy[0]) + self.polyline(0, 90, sh[0], 90) + + self.move(tw, th, move) + + def yCB(self, width): + t = self.thickness + posx = -0.5 * t + for dx in self.sx[:-1]: + posx += dx + t + self.fingerHolesAt(posx, 0, width, 90) + + + def render(self): + # Add slat wall edges + s = edges.SlatWallSettings(self.thickness, True, + **self.edgesettings.get("SlatWall", {})) + s.edgeObjects(self) + self.slatWallHolesAt = edges.SlatWallHoles(self, s) + + self.extra_height = 20 + t = self.thickness + sx, sy, sh = self.sx, self.sy, self.sh + self.x = x = sum(sx) + len(sx)*t - t + self.y = y = sum(sy) + + for w in sy: + self.rectangularWall( + x, w, "eheh", callback=[lambda:self.yCB(w)], move="up") + if self.braceheight: + self.rectangularWall( + x, self.braceheight, "eheh", + callback=[lambda:self.yCB(self.braceheight)], move="up") + + for i in range(len(sx) + 1): + self.yWall(move="right")