2023-01-06 09:59:58 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Copyright (C) 2013-2014 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 *
|
2023-04-07 21:32:28 +02:00
|
|
|
from boxes import lids
|
2023-01-06 09:59:58 +01:00
|
|
|
|
|
|
|
class GridfinityBase(Boxes):
|
2023-02-05 00:05:53 +01:00
|
|
|
"""A parameterized Gridfinity base"""
|
2023-01-06 09:59:58 +01:00
|
|
|
|
|
|
|
description = """This is a configurable gridfinity base. This
|
|
|
|
design is based on
|
|
|
|
<a href="https://www.youtube.com/watch?app=desktop&v=ra_9zU-mnl8">Zach Freedman's Gridfinity system</a>"""
|
|
|
|
|
|
|
|
ui_group = "Tray"
|
|
|
|
|
2023-01-08 19:41:02 +01:00
|
|
|
def __init__(self) -> None:
|
2023-01-06 09:59:58 +01:00
|
|
|
Boxes.__init__(self)
|
|
|
|
self.addSettingsArgs(edges.FingerJointSettings, space=4, finger=4)
|
2023-04-07 21:32:28 +02:00
|
|
|
self.addSettingsArgs(lids.LidSettings)
|
2023-01-06 09:59:58 +01:00
|
|
|
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)")
|
|
|
|
self.argparser.add_argument("--m", type=float, default=0.5, help="Extra margin around the gridfinity base to allow it to drop into the carrier (mm)")
|
|
|
|
self.argparser.add_argument(
|
|
|
|
"--bottom_edge", action="store",
|
|
|
|
type=ArgparseEdgeType("Fhse"), choices=list("Fhse"),
|
|
|
|
default='F',
|
|
|
|
help="edge type for bottom edge")
|
|
|
|
self.argparser.add_argument("--pitch", type=int, default=42, help="The Gridfinity pitch, in mm. Should always be 42.")
|
|
|
|
self.argparser.add_argument("--opening", type=int, default=38, help="The cutout for each grid opening. Typical is 38.")
|
|
|
|
|
|
|
|
def generate_grid(self):
|
|
|
|
pitch = self.pitch
|
|
|
|
nx, ny = self.x, self.y
|
|
|
|
opening = self.opening
|
|
|
|
for col in range(nx):
|
|
|
|
for row in range(ny):
|
|
|
|
lx = col*pitch+pitch/2
|
|
|
|
ly = row*pitch+pitch/2
|
|
|
|
self.rectangularHole(lx, ly, opening, opening)
|
|
|
|
|
|
|
|
def create_base_plate(self):
|
|
|
|
pitch = self.pitch
|
|
|
|
nx, ny = self.x, self.y
|
|
|
|
opening = self.opening
|
|
|
|
self.rectangularWall(nx*pitch, ny*pitch, move="up", callback=[self.generate_grid])
|
|
|
|
return
|
|
|
|
|
|
|
|
def create_tray(self):
|
|
|
|
pitch = self.pitch
|
|
|
|
nx, ny = self.x, self.y
|
|
|
|
margin = self.m
|
|
|
|
x, y, h = nx*pitch, ny*pitch, self.h
|
|
|
|
t = self.thickness
|
|
|
|
x += 2*margin
|
|
|
|
y += 2*margin
|
|
|
|
t1, t2, t3, t4 = "eeee"
|
|
|
|
b = self.edges.get(self.bottom_edge, self.edges["F"])
|
|
|
|
sideedge = "F" # if self.vertical_edges == "finger joints" else "h"
|
|
|
|
|
2023-04-07 21:32:28 +02:00
|
|
|
self.rectangularWall(x, h, [b, sideedge, t1, sideedge],
|
|
|
|
ignore_widths=[1, 6], move="right")
|
2023-01-06 09:59:58 +01:00
|
|
|
self.rectangularWall(y, h, [b, "f", t2, "f"],
|
|
|
|
ignore_widths=[1, 6], move="up")
|
|
|
|
self.rectangularWall(y, h, [b, "f", t4, "f"],
|
2023-04-07 21:32:28 +02:00
|
|
|
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")
|
|
|
|
|
2023-01-06 09:59:58 +01:00
|
|
|
return
|
|
|
|
|
|
|
|
def render(self):
|
|
|
|
self.create_base_plate()
|
|
|
|
self.create_tray()
|
2023-04-07 21:32:28 +02:00
|
|
|
self.lid(self.x*self.pitch + 2*self.m,
|
|
|
|
self.y*self.pitch + 2*self.m)
|