Add Lid option to more Generators
* DividerTray * DrillBox * GridfinityBase * GridfinityTrayLayout * SmallPartsTray * SmallPartsTray2 * TrayLayout * TypeTray Related: #128 Related: #277
This commit is contained in:
parent
fa760ded47
commit
7bd0ab9e7d
|
@ -19,7 +19,7 @@ from __future__ import annotations
|
|||
import math
|
||||
from functools import partial
|
||||
|
||||
from boxes import Boxes, edges, boolarg
|
||||
from boxes import Boxes, edges, boolarg, lids
|
||||
|
||||
|
||||
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)
|
||||
self.addSettingsArgs(edges.FingerJointSettings)
|
||||
self.addSettingsArgs(edges.HandleEdgeSettings)
|
||||
self.addSettingsArgs(lids.LidSettings)
|
||||
self.buildArgParser("sx", "sy", "h", "outside")
|
||||
self.addSettingsArgs(SlotSettings)
|
||||
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)
|
||||
)
|
||||
|
||||
self.lid(facing_wall_length, side_wall_length)
|
||||
|
||||
# Switch to right side of the file
|
||||
self.ctx.restore()
|
||||
self.rectangularWall(
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from boxes import Boxes, edges, Color, ArgparseEdgeType
|
||||
from boxes.lids import _TopEdge
|
||||
from boxes.lids import _TopEdge, LidSettings
|
||||
|
||||
class DrillBox(_TopEdge):
|
||||
"""A parametrized box for drills"""
|
||||
|
@ -32,6 +32,7 @@ class DrillBox(_TopEdge):
|
|||
self.addSettingsArgs(edges.RoundedTriangleEdgeSettings, outset=1)
|
||||
self.addSettingsArgs(edges.StackableSettings)
|
||||
self.addSettingsArgs(edges.MountingSettings)
|
||||
self.addSettingsArgs(LidSettings)
|
||||
self.argparser.add_argument(
|
||||
"--top_edge", action="store",
|
||||
type=ArgparseEdgeType("eStG"), choices=list("eStG"),
|
||||
|
@ -125,3 +126,4 @@ class DrillBox(_TopEdge):
|
|||
x, y, "ffff",
|
||||
callback=[lambda: self.drillholes(description=True)],
|
||||
move="right")
|
||||
self.lid(x, y, self.top_edge)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from boxes import *
|
||||
from boxes import lids
|
||||
|
||||
class GridfinityBase(Boxes):
|
||||
"""A parameterized Gridfinity base"""
|
||||
|
@ -28,6 +29,7 @@ class GridfinityBase(Boxes):
|
|||
def __init__(self) -> None:
|
||||
Boxes.__init__(self)
|
||||
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("--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)")
|
||||
|
@ -69,23 +71,22 @@ class GridfinityBase(Boxes):
|
|||
b = self.edges.get(self.bottom_edge, self.edges["F"])
|
||||
sideedge = "F" # if self.vertical_edges == "finger joints" else "h"
|
||||
|
||||
with self.saved_context():
|
||||
self.rectangularWall(x, h, [b, sideedge, t1, sideedge],
|
||||
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(x, h, [b, sideedge, t1, sideedge],
|
||||
ignore_widths=[1, 6], move="right")
|
||||
self.rectangularWall(y, h, [b, "f", t2, "f"],
|
||||
ignore_widths=[1, 6], move="up")
|
||||
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
|
||||
|
||||
def render(self):
|
||||
self.create_base_plate()
|
||||
self.create_tray()
|
||||
self.lid(self.x*self.pitch + 2*self.m,
|
||||
self.y*self.pitch + 2*self.m)
|
||||
|
|
|
@ -2,7 +2,7 @@ import boxes
|
|||
from boxes import Boxes
|
||||
from boxes.generators.traylayout import TrayLayout
|
||||
from boxes.Color import Color
|
||||
from boxes import restore
|
||||
from boxes import restore, lids
|
||||
|
||||
class GridfinityTrayLayout(TrayLayout):
|
||||
"""A Gridfinity Tray Generator based on TrayLayout"""
|
||||
|
@ -25,6 +25,7 @@ this compartment.
|
|||
def __init__(self) -> None:
|
||||
Boxes.__init__(self)
|
||||
self.addSettingsArgs(boxes.edges.FingerJointSettings)
|
||||
self.addSettingsArgs(lids.LidSettings)
|
||||
self.buildArgParser(h=50)
|
||||
self.outside = True # We're *always* outside for gridfinity
|
||||
self.pitch = 42.0 # gridfinity pitch is defined as 42.
|
||||
|
@ -103,9 +104,13 @@ this compartment.
|
|||
|
||||
self.prepare()
|
||||
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],
|
||||
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")
|
||||
|
||||
move="up only")
|
||||
self.lid(sum(self.x) + (len(self.x)-1) * self.thickness,
|
||||
sum(self.y) + (len(self.y)-1) * self.thickness)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from boxes import *
|
||||
from boxes import lids
|
||||
from boxes.edges import CompoundEdge
|
||||
|
||||
class SmallPartsTray(Boxes):
|
||||
|
@ -27,6 +28,7 @@ class SmallPartsTray(Boxes):
|
|||
|
||||
self.addSettingsArgs(edges.FingerJointSettings)
|
||||
# self.addSettingsArgs(edges.StackableSettings)
|
||||
self.addSettingsArgs(lids.LidSettings)
|
||||
|
||||
self.buildArgParser(sx="50*3", y=100, h=30, outside=True)
|
||||
self.argparser.add_argument(
|
||||
|
@ -243,7 +245,11 @@ class SmallPartsTray(Boxes):
|
|||
|
||||
|
||||
if self.two_sided:
|
||||
for l in self.sx:
|
||||
self.render_simple_tray_divider(l, h, move="right")
|
||||
with self.saved_context():
|
||||
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)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from boxes import *
|
||||
from boxes.lids import _TopEdge
|
||||
from boxes.lids import _TopEdge, LidSettings
|
||||
|
||||
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)
|
||||
self.addTopEdgeSettings(fingerjoint={"surroundingspaces": 1.0},
|
||||
roundedtriangle={"outset" : 1})
|
||||
self.addSettingsArgs(LidSettings)
|
||||
self.buildArgParser("sx", "sy", "hi", "outside", h=30)
|
||||
# "bottom_edge", "top_edge")
|
||||
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)],
|
||||
move="up", label="floor front side")
|
||||
floors.append(hi-t2)
|
||||
print(y, sum(floors), floors)
|
||||
|
||||
# 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
|
||||
self.drawLid(x, y, self.top_edge) # XXX deal with front
|
||||
self.lid(x, y, self.top_edge)
|
||||
|
||||
self.ctx.restore()
|
||||
self.rectangularWall(x, hi, "ffff", move="right only")
|
||||
|
|
|
@ -17,7 +17,7 @@ from __future__ import annotations
|
|||
|
||||
import boxes
|
||||
from boxes import *
|
||||
|
||||
from boxes import lids
|
||||
|
||||
class TrayLayoutFile(Boxes):
|
||||
"""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:
|
||||
super().__init__()
|
||||
self.addSettingsArgs(boxes.edges.FingerJointSettings)
|
||||
self.addSettingsArgs(lids.LidSettings)
|
||||
self.buildArgParser("h", "hi", "outside", "sx", "sy")
|
||||
if self.UI == "web":
|
||||
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:
|
||||
self.prepare()
|
||||
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)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from boxes import *
|
||||
from boxes.lids import _TopEdge
|
||||
from boxes.lids import _TopEdge, LidSettings
|
||||
|
||||
class TypeTray(_TopEdge):
|
||||
"""Type tray - allows only continuous walls"""
|
||||
|
@ -26,6 +26,7 @@ class TypeTray(_TopEdge):
|
|||
Boxes.__init__(self)
|
||||
self.addTopEdgeSettings(fingerjoint={"surroundingspaces": 0.5},
|
||||
roundedtriangle={"outset" : 1})
|
||||
self.addSettingsArgs(lids.LidSettings)
|
||||
self.buildArgParser("sx", "sy", "h", "hi", "outside", "bottom_edge",
|
||||
"top_edge")
|
||||
self.argparser.add_argument(
|
||||
|
@ -156,6 +157,7 @@ class TypeTray(_TopEdge):
|
|||
self.xSlots, self.ySlots], move="up", label="top")
|
||||
else:
|
||||
self.drawLid(x, y, self.top_edge)
|
||||
self.lid(x, y, self.top_edge)
|
||||
|
||||
self.ctx.restore()
|
||||
self.rectangularWall(x, hi, "ffff", move="right only")
|
||||
|
|
|
@ -63,7 +63,7 @@ class Lid:
|
|||
if style == "flat":
|
||||
self.rectangularWall(x, y, "eeee",
|
||||
callback=[self.handleCB(x, y)],
|
||||
move="right", label="lid bottom")
|
||||
move="up", label="lid bottom")
|
||||
self.rectangularWall(x, y, "EEEE",
|
||||
callback=[self.handleCB(x, y)],
|
||||
move="up", label="lid top")
|
||||
|
|
Loading…
Reference in New Issue