refactor: DividerTray add notches in wall by default
This commit is contained in:
parent
6cffe5e6a8
commit
95e5c26b4d
|
@ -31,6 +31,12 @@ class DividerTray(Boxes):
|
|||
Boxes.__init__(self)
|
||||
self.addSettingsArgs(edges.FingerJointSettings)
|
||||
self.buildArgParser("sx", "sy", "h", "outside")
|
||||
self.argparser.add_argument(
|
||||
"--notches_in_wall",
|
||||
type=boolarg,
|
||||
default=True,
|
||||
help="generate the same notches on the walls that are on the dividers",
|
||||
)
|
||||
self.argparser.add_argument(
|
||||
"--slot_depth", type=float, default=20, help="depth of the slot in mm"
|
||||
)
|
||||
|
@ -126,6 +132,17 @@ class DividerTray(Boxes):
|
|||
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"
|
||||
upper_edge = (
|
||||
DividerNotchesEdge(
|
||||
self,
|
||||
list(reversed(self.sx)),
|
||||
self.divider_upper_notch_radius,
|
||||
self.divider_lower_notch_radius,
|
||||
self.divider_notch_depth,
|
||||
)
|
||||
if self.notches_in_wall
|
||||
else "e"
|
||||
)
|
||||
for _ in range(2):
|
||||
self.rectangularWall(
|
||||
facing_wall_length,
|
||||
|
@ -133,7 +150,7 @@ class DividerTray(Boxes):
|
|||
[
|
||||
bottom_edge(self.bottom),
|
||||
side_edge(self.right_wall),
|
||||
"e",
|
||||
upper_edge,
|
||||
side_edge(self.left_wall),
|
||||
],
|
||||
callback=[partial(self.generate_finger_holes, self.h)],
|
||||
|
@ -248,8 +265,6 @@ class DividerTray(Boxes):
|
|||
|
||||
# Upper edge with a finger notch
|
||||
|
||||
upper_radius = self.divider_upper_notch_radius
|
||||
lower_radius = self.divider_lower_notch_radius
|
||||
play = 0.05 * self.thickness
|
||||
|
||||
# Upper: first tab width
|
||||
|
@ -258,24 +273,13 @@ class DividerTray(Boxes):
|
|||
for nr, width in enumerate(widths):
|
||||
if nr > 0:
|
||||
self.edge(self.thickness)
|
||||
|
||||
# Upper: divider width (with notch if possible)
|
||||
upper_third = (width - 2 * upper_radius - 2 * lower_radius) / 3
|
||||
if upper_third > 0:
|
||||
self.polyline(
|
||||
upper_third,
|
||||
(90, upper_radius),
|
||||
self.divider_notch_depth - upper_radius - lower_radius,
|
||||
(-90, lower_radius),
|
||||
upper_third,
|
||||
(-90, lower_radius),
|
||||
self.divider_notch_depth - upper_radius - lower_radius,
|
||||
(90, upper_radius),
|
||||
upper_third,
|
||||
)
|
||||
else:
|
||||
# if there isn't enough room for the radius, we don't use it
|
||||
self.edge(width)
|
||||
DividerNotchesEdge(
|
||||
self,
|
||||
[width],
|
||||
self.divider_upper_notch_radius,
|
||||
self.divider_lower_notch_radius,
|
||||
self.divider_notch_depth,
|
||||
)(width)
|
||||
|
||||
self.polyline(
|
||||
# Upper: second tab width if needed
|
||||
|
@ -517,6 +521,49 @@ class SlotDescriptionsGenerator:
|
|||
return descriptions
|
||||
|
||||
|
||||
class DividerNotchesEdge(edges.BaseEdge):
|
||||
"""Edge with multiple notches for easier access to dividers"""
|
||||
|
||||
description = "Edge with multiple notches for easier access to dividers"
|
||||
|
||||
def __init__(self, boxes, sx, upper_radius, lower_radius, depth):
|
||||
|
||||
super(DividerNotchesEdge, self).__init__(boxes, None)
|
||||
|
||||
self.sx = sx
|
||||
self.upper_radius = upper_radius
|
||||
self.lower_radius = lower_radius
|
||||
self.depth = depth
|
||||
|
||||
def __call__(self, _, **kw):
|
||||
first = True
|
||||
for width in self.sx:
|
||||
if first:
|
||||
first = False
|
||||
else:
|
||||
self.edge(self.thickness)
|
||||
self.edge_with_notch(width)
|
||||
|
||||
def edge_with_notch(self, width):
|
||||
# Upper: divider width (with notch if possible)
|
||||
upper_third = (width - 2 * self.upper_radius - 2 * self.lower_radius) / 3
|
||||
if upper_third > 0:
|
||||
self.polyline(
|
||||
upper_third,
|
||||
(90, self.upper_radius),
|
||||
self.depth - self.upper_radius - self.lower_radius,
|
||||
(-90, self.lower_radius),
|
||||
upper_third,
|
||||
(-90, self.lower_radius),
|
||||
self.depth - self.upper_radius - self.lower_radius,
|
||||
(90, self.upper_radius),
|
||||
upper_third,
|
||||
)
|
||||
else:
|
||||
# if there isn't enough room for the radius, we don't use it
|
||||
self.edge(width)
|
||||
|
||||
|
||||
class DividerSlotsEdge(edges.BaseEdge):
|
||||
"""Edge with multiple angled rounded slots for dividers"""
|
||||
|
||||
|
|
Loading…
Reference in New Issue