Skip to content

Commit

Permalink
WallRack: Add side_edges parameter
Browse files Browse the repository at this point in the history
Default is using h edges (finger holes) to make the rack stronger.

Changes the placement of holes in the back wall to the line up the bottom of the bottom shelf with the back wall (except when side_edges=F and flat_bottom=off is selected)
  • Loading branch information
florianfesti committed Feb 7, 2024
1 parent 680bb31 commit 8ae2a7f
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions boxes/generators/wallrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,31 @@ def __init__(self):
self.argparser.add_argument(
"--back_height", action="store", type=float, default=1.5,
help="height of the back as fraction of the front height")
self.argparser.add_argument(
"--side_edges", action="store",
type=ArgparseEdgeType("Fh"), choices=list("Fh"),
default="h", help="edge type holding the shelfs together")
self.argparser.add_argument(
"--flat_bottom", type=boolarg, default=False, help="Make bottom Flat, so that the rack can also stand")

def generate_shelves(self, x, y, front_height, back_height):
se = self.side_edges
for i in range(len(self.sh)):
self.rectangularWall(x, y, "ffff", move="up", label=f"shelf {i+1}")
self.rectangularWall(x, front_height, "Ffef", move="up", label=f"front lip {i+1}")
self.trapezoidWall(y, front_height, back_height, "FfeF", move="right", label=f"right lip {i+1}")
self.trapezoidWall(y, front_height, back_height, "FfeF", move="up", label=f"left lip {i+1}")
self.rectangularWall(x, front_height, se + "fef", move="up", label=f"front lip {i+1}")
self.trapezoidWall(y, front_height, back_height, se + "fe" + se, move="right", label=f"right lip {i+1}")
self.trapezoidWall(y, front_height, back_height, se + "fe" + se, move="up", label=f"left lip {i+1}")
self.move(y + self.thickness*2, back_height, "left", before=True)

#Generate finger holes for back part
def generate_finger_holes(self, x, back_height):
t = self.thickness
offset = -self.sh[0] + (0 if self.flat_bottom else t)
for i in self.sh:
offset += i
pos_y = offset
self.fingerHolesAt(t*0.5, pos_y, x, 0)
pos_y += t*0.5
self.fingerHolesAt(0, pos_y, back_height, 90)
self.fingerHolesAt(x+t, pos_y, back_height, 90)
pos_y = 0
for h in self.sh:
self.fingerHolesAt(t*0.5, pos_y + 0.5*t, x, 0)
self.fingerHolesAt(0, pos_y + t, back_height, 90)
self.fingerHolesAt(x+t, pos_y + t, back_height, 90)
pos_y += h

def render(self):
x, y, front_height = self.x, self.y, self.wall_height
Expand All @@ -78,6 +81,7 @@ def render(self):
else:
total_height = sum(self.sh[:-1]) + back_height

self.rectangularWall(x+self.thickness, total_height, "EE" + self.top_edge + "E",
be = "e" if self.flat_bottom and self.side_edges == "F" else "E"
self.rectangularWall(x+self.thickness, total_height, be + "E" + self.top_edge + "E",
callback=[partial(self.generate_finger_holes, x, back_height)], label="back wall", move="right")
self.generate_shelves(x, y, front_height, back_height)

0 comments on commit 8ae2a7f

Please sign in to comment.