diff --git a/boxes/generators/swwrenchholder.py b/boxes/generators/swwrenchholder.py new file mode 100644 index 0000000..9eb942a --- /dev/null +++ b/boxes/generators/swwrenchholder.py @@ -0,0 +1,97 @@ +#!/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 SlottedEdge(edges.Edge): + + def __call__(self, length, **kw): + + n = self.number + t = self.thickness + + self.polyline(t, 45) + + l = t + + for i in range(n): + w = self.min_width * ((n-i)/n) + self.max_width * (i / n) + s = self.min_strength * ((n-i)/n) + self.max_strength * (i / n) + if i == n-1: + self.polyline(w-s/2+2*s, (-180, s/2), w - 0.5*s, + (180, s/2)) + l += s *2 * 2**0.5 + else: + self.polyline(w-s/2+2*s, (-180, s/2), w - 0.5*s, + (180, s/2)) + l += s *2 * 2**0.5 + self.polyline(0, -45) + self.edge(length-l) + +class SlatwallWrenchHolder(Boxes): + """Hold a set of wrenches at a slat wall""" + + ui_group = "SlatWall" + + def __init__(self): + Boxes.__init__(self) + + self.addSettingsArgs(edges.FingerJointSettings) + self.addSettingsArgs(edges.SlatWallSettings) + + # remove cli params you do not need + self.buildArgParser(x=100) + # Add non default cli params if needed (see argparse std lib) + self.argparser.add_argument( + "--depth", action="store", type=float, default=30.0, + help="depth of the sides") + self.argparser.add_argument( + "--number", action="store", type=int, default=11, + help="number of wrenches") + self.argparser.add_argument( + "--min_width", action="store", type=float, default=8.0, + help="width of smallest wrench") + self.argparser.add_argument( + "--max_width", action="store", type=float, default=25.0, + help="width of largest wrench") + self.argparser.add_argument( + "--min_strength", action="store", type=float, default=3.0, + help="strength of smallest wrench") + self.argparser.add_argument( + "--max_strength", action="store", type=float, default=5.0, + help="strength of largest wrench") + + 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) + + h = (self.number * (self.min_strength + self.max_strength) * 2**0.5 + + self.max_width) + t = self.thickness + x = self.x-2*t + + self.rectangularWall(self.depth, h, + ["e", "B", "e", SlottedEdge(self, None)], + move="right") + self.rectangularWall(self.depth, h, + ["e", "B", "e", SlottedEdge(self, None)], + move="right") + self.rectangularWall(x, h, "eDed", + # callback=[lambda:self.fingerHolesAt(x/2, 0, h, 90)], + move="right")