From 777e79afc1c9771d207a36864b57b3ca13aa50b0 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Mon, 18 Jul 2022 22:29:39 +0200 Subject: [PATCH] New generator: BirdHouse Still untested --- boxes/generators/birdhouse.py | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 boxes/generators/birdhouse.py diff --git a/boxes/generators/birdhouse.py b/boxes/generators/birdhouse.py new file mode 100644 index 0000000..e79d6df --- /dev/null +++ b/boxes/generators/birdhouse.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +# Copyright (C) 2013-2022 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 BirdHouse(Boxes): + """Simple Bird House""" + + ui_group = "Unstable" # "Misc" + + def __init__(self): + Boxes.__init__(self) + + self.addSettingsArgs(edges.FingerJointSettings, finger=10.0,space=10.0) + + # remove cli params you do not need + self.buildArgParser(x=200, y=200, h=200) + + def side(self, x, h, edges="hFffF", callback=None, move=None): + angles = (90, 45, 90, 45, 90) + roof = 2**0.5 * x / 2 + lengths = (x, h, roof, roof, h) + + edges = [self.edges.get(e, e) for e in edges] + edges.append(edges[0]) # wrap arround + + tw = x + edges[1].spacing() + th = h + roof + max(edges[2].spacing(), edges[2].spacing()) + + if self.move(tw, th, move, True): + return + + for i in range(5): + self.cc(callback, i, y=self.burn+edges[i].startwidth()) + edges[i](lengths[i]) + self.edgeCorner(edges[i], edges[i+1], angles[i]) + + self.move(tw, th, move) + + def side_hole(self, width): + self.rectangularHole(width/2, self.h/2, + 0.75*width, 0.75*self.h, + r=self.thickness) + + def render(self): + x, y, h = self.x, self.y, self.h + + roof = 2**0.5 * x / 2 + + cbx = [lambda: self.side_hole(x)] + cby = [lambda: self.side_hole(y)] + + self.side(x, h, callback=cby, move="right") + self.side(x, h, callback=cby, move="right") + self.rectangularWall(y, h, "hfef", callback=cby, move="right") + self.rectangularWall(y, h, "hfef", callback=cby, move="right") + self.rectangularWall(x, y, "ffff", move="right") + self.flangedWall(y, roof, "ehfh", r=0.2*roof, flanges=[0.2*roof], move="right") + self.flangedWall(y, roof, "ehFh", r=0.2*roof, flanges=[0.2*roof], move="right")