Add Lid option to more Generators

* DividerTray
 * DrillBox
 * GridfinityBase
 * GridfinityTrayLayout
 * SmallPartsTray
 * SmallPartsTray2
 * TrayLayout
 * TypeTray

Related: #128
Related: #277
This commit is contained in:
Florian Festi 2023-04-07 21:32:28 +02:00
parent fa760ded47
commit 7bd0ab9e7d
9 changed files with 52 additions and 29 deletions

View File

@ -19,7 +19,7 @@ from __future__ import annotations
import math import math
from functools import partial from functools import partial
from boxes import Boxes, edges, boolarg from boxes import Boxes, edges, boolarg, lids
class NotchSettings(edges.Settings): class NotchSettings(edges.Settings):
@ -94,6 +94,7 @@ You will likely need to cut each of the dividers you want multiple times.
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings) self.addSettingsArgs(edges.FingerJointSettings)
self.addSettingsArgs(edges.HandleEdgeSettings) self.addSettingsArgs(edges.HandleEdgeSettings)
self.addSettingsArgs(lids.LidSettings)
self.buildArgParser("sx", "sy", "h", "outside") self.buildArgParser("sx", "sy", "h", "outside")
self.addSettingsArgs(SlotSettings) self.addSettingsArgs(SlotSettings)
self.addSettingsArgs(NotchSettings) self.addSettingsArgs(NotchSettings)
@ -194,6 +195,8 @@ You will likely need to cut each of the dividers you want multiple times.
side_wall_length, self.h, [be, "f", se, "f"], move="up", label="Sidepiece " + str(_ + 1) side_wall_length, self.h, [be, "f", se, "f"], move="up", label="Sidepiece " + str(_ + 1)
) )
self.lid(facing_wall_length, side_wall_length)
# Switch to right side of the file # Switch to right side of the file
self.ctx.restore() self.ctx.restore()
self.rectangularWall( self.rectangularWall(

View File

@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from boxes import Boxes, edges, Color, ArgparseEdgeType from boxes import Boxes, edges, Color, ArgparseEdgeType
from boxes.lids import _TopEdge from boxes.lids import _TopEdge, LidSettings
class DrillBox(_TopEdge): class DrillBox(_TopEdge):
"""A parametrized box for drills""" """A parametrized box for drills"""
@ -32,6 +32,7 @@ class DrillBox(_TopEdge):
self.addSettingsArgs(edges.RoundedTriangleEdgeSettings, outset=1) self.addSettingsArgs(edges.RoundedTriangleEdgeSettings, outset=1)
self.addSettingsArgs(edges.StackableSettings) self.addSettingsArgs(edges.StackableSettings)
self.addSettingsArgs(edges.MountingSettings) self.addSettingsArgs(edges.MountingSettings)
self.addSettingsArgs(LidSettings)
self.argparser.add_argument( self.argparser.add_argument(
"--top_edge", action="store", "--top_edge", action="store",
type=ArgparseEdgeType("eStG"), choices=list("eStG"), type=ArgparseEdgeType("eStG"), choices=list("eStG"),
@ -125,3 +126,4 @@ class DrillBox(_TopEdge):
x, y, "ffff", x, y, "ffff",
callback=[lambda: self.drillholes(description=True)], callback=[lambda: self.drillholes(description=True)],
move="right") move="right")
self.lid(x, y, self.top_edge)

View File

@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from boxes import * from boxes import *
from boxes import lids
class GridfinityBase(Boxes): class GridfinityBase(Boxes):
"""A parameterized Gridfinity base""" """A parameterized Gridfinity base"""
@ -28,6 +29,7 @@ class GridfinityBase(Boxes):
def __init__(self) -> None: def __init__(self) -> None:
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings, space=4, finger=4) self.addSettingsArgs(edges.FingerJointSettings, space=4, finger=4)
self.addSettingsArgs(lids.LidSettings)
self.argparser.add_argument("--x", type=int, default=3, help="number of grids in X direction") self.argparser.add_argument("--x", type=int, default=3, help="number of grids in X direction")
self.argparser.add_argument("--y", type=int, default=2, help="number of grids in Y direction") self.argparser.add_argument("--y", type=int, default=2, help="number of grids in Y direction")
self.argparser.add_argument("--h", type=float, default=7*3, help="height of sidewalls of the tray (mm)") self.argparser.add_argument("--h", type=float, default=7*3, help="height of sidewalls of the tray (mm)")
@ -69,23 +71,22 @@ class GridfinityBase(Boxes):
b = self.edges.get(self.bottom_edge, self.edges["F"]) b = self.edges.get(self.bottom_edge, self.edges["F"])
sideedge = "F" # if self.vertical_edges == "finger joints" else "h" sideedge = "F" # if self.vertical_edges == "finger joints" else "h"
with self.saved_context(): self.rectangularWall(x, h, [b, sideedge, t1, sideedge],
self.rectangularWall(x, h, [b, sideedge, t1, sideedge], ignore_widths=[1, 6], move="right")
ignore_widths=[1, 6], move="up")
self.rectangularWall(x, h, [b, sideedge, t3, sideedge],
ignore_widths=[1, 6], move="up")
if self.bottom_edge != "e":
self.rectangularWall(x, y, "ffff", move="up")
self.rectangularWall(x, h, [b, sideedge, t3, sideedge],
ignore_widths=[1, 6], move="right only")
self.rectangularWall(y, h, [b, "f", t2, "f"], self.rectangularWall(y, h, [b, "f", t2, "f"],
ignore_widths=[1, 6], move="up") ignore_widths=[1, 6], move="up")
self.rectangularWall(y, h, [b, "f", t4, "f"], self.rectangularWall(y, h, [b, "f", t4, "f"],
ignore_widths=[1, 6], move="up") ignore_widths=[1, 6], move="")
self.rectangularWall(x, h, [b, sideedge, t3, sideedge],
ignore_widths=[1, 6], move="left up")
if self.bottom_edge != "e":
self.rectangularWall(x, y, "ffff", move="up")
return return
def render(self): def render(self):
self.create_base_plate() self.create_base_plate()
self.create_tray() self.create_tray()
self.lid(self.x*self.pitch + 2*self.m,
self.y*self.pitch + 2*self.m)

View File

@ -2,7 +2,7 @@ import boxes
from boxes import Boxes from boxes import Boxes
from boxes.generators.traylayout import TrayLayout from boxes.generators.traylayout import TrayLayout
from boxes.Color import Color from boxes.Color import Color
from boxes import restore from boxes import restore, lids
class GridfinityTrayLayout(TrayLayout): class GridfinityTrayLayout(TrayLayout):
"""A Gridfinity Tray Generator based on TrayLayout""" """A Gridfinity Tray Generator based on TrayLayout"""
@ -25,6 +25,7 @@ this compartment.
def __init__(self) -> None: def __init__(self) -> None:
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(boxes.edges.FingerJointSettings) self.addSettingsArgs(boxes.edges.FingerJointSettings)
self.addSettingsArgs(lids.LidSettings)
self.buildArgParser(h=50) self.buildArgParser(h=50)
self.outside = True # We're *always* outside for gridfinity self.outside = True # We're *always* outside for gridfinity
self.pitch = 42.0 # gridfinity pitch is defined as 42. self.pitch = 42.0 # gridfinity pitch is defined as 42.
@ -103,9 +104,13 @@ this compartment.
self.prepare() self.prepare()
self.walls() self.walls()
with self.saved_context():
self.base_plate(callback=[self.baseplate_etching],
move="mirror right")
foot = self.opening - self.opening_margin
for i in range(min(self.nx * self.ny, 4)):
self.rectangularWall(foot, foot, move="right")
self.base_plate(callback=[self.baseplate_etching], self.base_plate(callback=[self.baseplate_etching],
move="mirror right") move="up only")
foot = self.opening - self.opening_margin self.lid(sum(self.x) + (len(self.x)-1) * self.thickness,
for i in range(min(self.nx * self.ny, 4)): sum(self.y) + (len(self.y)-1) * self.thickness)
self.rectangularWall(foot, foot, move="right")

View File

@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from boxes import * from boxes import *
from boxes import lids
from boxes.edges import CompoundEdge from boxes.edges import CompoundEdge
class SmallPartsTray(Boxes): class SmallPartsTray(Boxes):
@ -27,6 +28,7 @@ class SmallPartsTray(Boxes):
self.addSettingsArgs(edges.FingerJointSettings) self.addSettingsArgs(edges.FingerJointSettings)
# self.addSettingsArgs(edges.StackableSettings) # self.addSettingsArgs(edges.StackableSettings)
self.addSettingsArgs(lids.LidSettings)
self.buildArgParser(sx="50*3", y=100, h=30, outside=True) self.buildArgParser(sx="50*3", y=100, h=30, outside=True)
self.argparser.add_argument( self.argparser.add_argument(
@ -243,7 +245,11 @@ class SmallPartsTray(Boxes):
if self.two_sided: if self.two_sided:
for l in self.sx: with self.saved_context():
self.render_simple_tray_divider(l, h, move="right") for l in self.sx:
self.render_simple_tray_divider(l, h, move="right")
self.partsMatrix(len(self.sx), 0, "right", self.render_simple_tray_divider_feet) self.partsMatrix(len(self.sx), 0, "right", self.render_simple_tray_divider_feet)
self.render_simple_tray_divider(l, h, move="up only")
self.lid(x, y)

View File

@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from boxes import * from boxes import *
from boxes.lids import _TopEdge from boxes.lids import _TopEdge, LidSettings
class TopEdge(edges.BaseEdge): class TopEdge(edges.BaseEdge):
@ -55,6 +55,7 @@ If there are no inner front to back walls just add everything to one side wall a
Boxes.__init__(self) Boxes.__init__(self)
self.addTopEdgeSettings(fingerjoint={"surroundingspaces": 1.0}, self.addTopEdgeSettings(fingerjoint={"surroundingspaces": 1.0},
roundedtriangle={"outset" : 1}) roundedtriangle={"outset" : 1})
self.addSettingsArgs(LidSettings)
self.buildArgParser("sx", "sy", "hi", "outside", h=30) self.buildArgParser("sx", "sy", "hi", "outside", h=30)
# "bottom_edge", "top_edge") # "bottom_edge", "top_edge")
self.argparser.add_argument( self.argparser.add_argument(
@ -178,7 +179,6 @@ If there are no inner front to back walls just add everything to one side wall a
callback=[self.fingerHolesCB(self.sx, hi-t2)], callback=[self.fingerHolesCB(self.sx, hi-t2)],
move="up", label="floor front side") move="up", label="floor front side")
floors.append(hi-t2) floors.append(hi-t2)
print(y, sum(floors), floors)
# Inner walls # Inner walls
@ -198,6 +198,7 @@ If there are no inner front to back walls just add everything to one side wall a
# top / lid # top / lid
self.drawLid(x, y, self.top_edge) # XXX deal with front self.drawLid(x, y, self.top_edge) # XXX deal with front
self.lid(x, y, self.top_edge)
self.ctx.restore() self.ctx.restore()
self.rectangularWall(x, hi, "ffff", move="right only") self.rectangularWall(x, hi, "ffff", move="right only")

View File

@ -17,7 +17,7 @@ from __future__ import annotations
import boxes import boxes
from boxes import * from boxes import *
from boxes import lids
class TrayLayoutFile(Boxes): class TrayLayoutFile(Boxes):
"""Generate a layout file for a typetray.""" """Generate a layout file for a typetray."""
@ -101,6 +101,7 @@ You can replace the space characters representing the floor by a "X" to remove t
def __init__(self) -> None: def __init__(self) -> None:
super().__init__() super().__init__()
self.addSettingsArgs(boxes.edges.FingerJointSettings) self.addSettingsArgs(boxes.edges.FingerJointSettings)
self.addSettingsArgs(lids.LidSettings)
self.buildArgParser("h", "hi", "outside", "sx", "sy") self.buildArgParser("h", "hi", "outside", "sx", "sy")
if self.UI == "web": if self.UI == "web":
self.argparser.add_argument( self.argparser.add_argument(
@ -452,4 +453,6 @@ You can replace the space characters representing the floor by a "X" to remove t
def render(self) -> None: def render(self) -> None:
self.prepare() self.prepare()
self.walls() self.walls()
self.base_plate() self.base_plate(move="up")
self.lid(sum(self.x) + (len(self.x)-1) * self.thickness,
sum(self.y) + (len(self.y)-1) * self.thickness)

View File

@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from boxes import * from boxes import *
from boxes.lids import _TopEdge from boxes.lids import _TopEdge, LidSettings
class TypeTray(_TopEdge): class TypeTray(_TopEdge):
"""Type tray - allows only continuous walls""" """Type tray - allows only continuous walls"""
@ -26,6 +26,7 @@ class TypeTray(_TopEdge):
Boxes.__init__(self) Boxes.__init__(self)
self.addTopEdgeSettings(fingerjoint={"surroundingspaces": 0.5}, self.addTopEdgeSettings(fingerjoint={"surroundingspaces": 0.5},
roundedtriangle={"outset" : 1}) roundedtriangle={"outset" : 1})
self.addSettingsArgs(lids.LidSettings)
self.buildArgParser("sx", "sy", "h", "hi", "outside", "bottom_edge", self.buildArgParser("sx", "sy", "h", "hi", "outside", "bottom_edge",
"top_edge") "top_edge")
self.argparser.add_argument( self.argparser.add_argument(
@ -156,6 +157,7 @@ class TypeTray(_TopEdge):
self.xSlots, self.ySlots], move="up", label="top") self.xSlots, self.ySlots], move="up", label="top")
else: else:
self.drawLid(x, y, self.top_edge) self.drawLid(x, y, self.top_edge)
self.lid(x, y, self.top_edge)
self.ctx.restore() self.ctx.restore()
self.rectangularWall(x, hi, "ffff", move="right only") self.rectangularWall(x, hi, "ffff", move="right only")

View File

@ -63,7 +63,7 @@ class Lid:
if style == "flat": if style == "flat":
self.rectangularWall(x, y, "eeee", self.rectangularWall(x, y, "eeee",
callback=[self.handleCB(x, y)], callback=[self.handleCB(x, y)],
move="right", label="lid bottom") move="up", label="lid bottom")
self.rectangularWall(x, y, "EEEE", self.rectangularWall(x, y, "EEEE",
callback=[self.handleCB(x, y)], callback=[self.handleCB(x, y)],
move="up", label="lid top") move="up", label="lid top")