BirdHouse: Add overhang parameter

to allow making the roof bigger and better looking.
Declare stable by moving to "Misc"

Resolves: #414
This commit is contained in:
Florian Festi 2023-01-17 17:25:34 +01:00
parent 9a9499e405
commit 122d365914
1 changed files with 33 additions and 7 deletions

View File

@ -19,15 +19,16 @@ from boxes import *
class BirdHouse(Boxes):
"""Simple Bird House"""
ui_group = "Unstable" # "Misc"
ui_group = "Misc"
def __init__(self) -> None:
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)
self.argparser.add_argument(
"--roof_overhang", action="store", type=float, default=0.4,
help="overhang as fraction of the roof length")
def side(self, x, h, edges="hfeffef", callback=None, move=None):
angles = (90, 0, 45, 90, 45, 0, 90)
@ -52,6 +53,30 @@ class BirdHouse(Boxes):
self.move(tw, th, move)
def roof(self, x, h, overhang, edges="eefe", move=None):
t = self.thickness
edges = [self.edges.get(e, e) for e in edges]
tw = x + 2*t + 2*overhang + edges[1].spacing() + edges[3].spacing()
th = h + 2*t + overhang + edges[0].spacing() + edges[2].spacing()
if self.move(tw, th, move, True):
return
self.moveTo(overhang + edges[3].spacing(), edges[0].margin())
edges[0](x + 2*t)
self.corner(90, overhang)
edges[1](h + 2*t)
self.edgeCorner(edges[1], edges[2])
self.fingerHolesAt(overhang + 0.5*t, edges[2].startwidth(), h, 90)
self.fingerHolesAt(x + overhang + 1.5*t, edges[2].startwidth(), h, 90)
edges[2](x + 2*t + 2*overhang)
self.edgeCorner(edges[2], edges[3])
edges[3](h + 2*t)
self.corner(90, overhang)
self.move(tw, th, move)
def side_hole(self, width):
self.rectangularHole(width/2, self.h/2,
0.75*width, 0.75*self.h,
@ -61,7 +86,8 @@ class BirdHouse(Boxes):
x, y, h = self.x, self.y, self.h
roof = 2**0.5 * x / 2
overhang = roof * self.roof_overhang
cbx = [lambda: self.side_hole(x)]
cby = [lambda: self.side_hole(y)]
@ -70,6 +96,6 @@ class BirdHouse(Boxes):
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.edges["h"].settings.setValues(self.thickness, relative=False, edge_width=0.1*roof)
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")
self.edges["h"].settings.setValues(self.thickness, relative=False, edge_width=overhang)
self.roof(y, roof, overhang, "eefe", move="right")
self.roof(y, roof, overhang, "eeFe", move="right")