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

Add a bottom to the divider tray. #204

Closed
wants to merge 1 commit into from
Closed
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
24 changes: 18 additions & 6 deletions boxes/generators/dividertray.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from boxes import Boxes, edges, boolarg
import math

from functools import partial

class DividerTray(Boxes):
"""Divider tray - rows and dividers"""
Expand Down Expand Up @@ -84,6 +84,12 @@ def __init__(self):
default=True,
help="generate wall on the right side",
)
self.argparser.add_argument(
"--bottom",
type=boolarg,
default=False,
help="generate wall on the bottom",
)

def render(self):

Expand All @@ -107,12 +113,13 @@ def render(self):
# Facing walls (outer) with finger holes to support side walls
facing_wall_length = sum(self.sx) + self.thickness * (len(self.sx) - 1)
side_edge = lambda with_wall: "F" if with_wall else "e"
bottom_edge = lambda with_wall: "F" if with_wall else "e"
for _ in range(2):
self.rectangularWall(
facing_wall_length,
self.h,
["e", side_edge(self.right_wall), "e", side_edge(self.left_wall)],
callback=[self.generate_finger_holes],
[bottom_edge(self.bottom), side_edge(self.right_wall), "e", side_edge(self.left_wall)],
callback=[partial(self.generate_finger_holes, self.h)],
move="up",
)

Expand All @@ -121,7 +128,7 @@ def render(self):
for _ in range(side_walls_number):
se = DividerSlotsEdge(self, slot_descriptions.descriptions)
self.rectangularWall(
side_wall_length, self.h, ["e", "f", se, "f"], move="up"
side_wall_length, self.h, [bottom_edge(self.bottom), "f", se, "f"], move="up"
)

# Switch to right side of the file
Expand All @@ -130,6 +137,11 @@ def render(self):
max(facing_wall_length, side_wall_length), self.h, "ffff", move="right only"
)

# Bottom piece.
if self.bottom:
self.rectangularWall(facing_wall_length, side_wall_length, "ffff",
callback=[partial(self.generate_finger_holes, side_wall_length)], move="up")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a bit fishy. Shouldn't the edge type be "e" for the sides that don't have a side wall attached? As happens when left_wall or right_wall is False?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you might be right :-).


# Dividers
divider_height = (
# h, with angle adjustement
Expand Down Expand Up @@ -242,11 +254,11 @@ def generate_slot_descriptions(self, sections):

return descriptions

def generate_finger_holes(self):
def generate_finger_holes(self, length):
posx = -0.5 * self.thickness
for x in self.sx[:-1]:
posx += x + self.thickness
self.fingerHolesAt(posx, 0, self.h)
self.fingerHolesAt(posx, 0, length)

def generate_divider(self, width, height, move, only_one_wall=False):
second_tab_width = 0 if only_one_wall else self.thickness
Expand Down