Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create generator for wall mounted (spice) rack #573

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions boxes/generators/_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ def __init__(self) -> None:
# Uncomment the settings for the edge types you use
# use keyword args to set default values
# self.addSettingsArgs(edges.FingerJointSettings, finger=1.0,space=1.0)
# self.addSettingsArgs(edges.DoveTailSettings)
# self.addSettingsArgs(edges.StackableSettings)
# self.addSettingsArgs(edges.HingeSettings)
# self.addSettingsArgs(edges.SlideOnLidSettings)
# self.addSettingsArgs(edges.ClickSettings)
# self.addSettingsArgs(edges.FlexSettings)
# self.addSettingsArgs(edges.HandleEdgeSettings)
# self.addSettingsArgs(edges.RoundedTriangleEdgeSettings)
# self.addSettingsArgs(edges.MountingSettings)

# remove cli params you do not need
self.buildArgParser(x=100, sx="3*50", y=100, sy="3*50", h=100, hi=0)
Expand Down
91 changes: 91 additions & 0 deletions boxes/generators/wallrack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Copyright (C) 2013-2023 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 <http://www.gnu.org/licenses/>.

from boxes import *
from functools import partial


class WallRack(Boxes):
"""Rack spices or other things to be mounted on a wall"""

ui_group = "WallMounted"

def __init__(self):
Boxes.__init__(self)

self.addSettingsArgs(edges.FingerJointSettings, surroundingspaces=1.0)
self.addSettingsArgs(edges.MountingSettings)
self.addSettingsArgs(edges.HandleEdgeSettings)

self.buildArgParser(x=200, y=50, sh="100*3", outside=False)
self.argparser.add_argument(
"--top_edge", action="store",
type=ArgparseEdgeType("eEGy"), choices=list("eEGy"),
default="G", help="edge type for top edge")
self.argparser.add_argument("--full_height_top", type=boolarg, default=True, help="Add full height of topmost rack to the back panel")
self.argparser.add_argument(
"--wall_height", action="store", type=float, default=20.0,
help="height of walls")
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, 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
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
back_height = front_height * self.back_height
t = self.thickness
if self.outside:
x = self.adjustSize(x, "h", "f")
y = self.adjustSize(y)
front_height = self.adjustSize(front_height)
back_height = self.adjustSize(back_height)

if self.full_height_top:
total_height = sum(self.sh)
else:
total_height = sum(self.sh[:-1]) + back_height

be = "e" if self.flat_bottom and self.side_edges == "F" else "E"
if be == "E" and self.full_height_top:
total_height -= t

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)
Loading