2018-08-15 20:23:23 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# Copyright (C) 2013-2018 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 *
|
|
|
|
|
|
|
|
|
|
|
|
class TwoPiece(Boxes):
|
|
|
|
"""A two piece box where top slips over the bottom half to form
|
|
|
|
the enclosure.
|
|
|
|
"""
|
|
|
|
|
2022-04-30 17:47:29 +02:00
|
|
|
description = """
|
2023-01-02 00:32:42 +01:00
|
|
|
Set *hi* larger than *h* to leave gap between the inner and outer shell. This can be used to make opening the box easier. Set *hi* smaller to only have a small inner ridge that will allow the content to be more visible after opening.
|
2022-04-30 17:47:29 +02:00
|
|
|
|
|
|
|
![Bottom view](static/samples/TwoPiece2.jpg)
|
|
|
|
"""
|
|
|
|
|
2018-08-15 20:23:23 +02:00
|
|
|
ui_group = "Box"
|
|
|
|
|
2023-01-08 19:41:02 +01:00
|
|
|
def __init__(self) -> None:
|
2018-08-15 20:23:23 +02:00
|
|
|
Boxes.__init__(self)
|
2020-08-04 19:31:51 +02:00
|
|
|
self.buildArgParser("x", "y", "h", "hi", "outside")
|
2018-08-15 20:23:23 +02:00
|
|
|
self.addSettingsArgs(edges.FingerJointSettings, finger=2.0, space=2.0)
|
|
|
|
|
|
|
|
self.argparser.add_argument(
|
2021-03-17 14:30:12 +01:00
|
|
|
"--play", action="store", type=float, default=0.15,
|
2023-01-02 00:32:42 +01:00
|
|
|
help="play between the two parts as multiple of the wall thickness")
|
2018-08-15 20:23:23 +02:00
|
|
|
|
|
|
|
def render(self):
|
|
|
|
# adjust to the variables you want in the local scope
|
|
|
|
x, y, h = self.x, self.y, self.h
|
2020-08-04 19:31:51 +02:00
|
|
|
hi = self.hi or self.h
|
2018-08-15 20:23:23 +02:00
|
|
|
t = self.thickness
|
|
|
|
p = self.play * t
|
|
|
|
|
|
|
|
if self.outside:
|
|
|
|
x -= 4*t + 2*p
|
|
|
|
y -= 4*t + 2*p
|
|
|
|
h -= 2 * t
|
2020-08-04 19:31:51 +02:00
|
|
|
hi -= 2 * t
|
2018-08-15 20:23:23 +02:00
|
|
|
|
|
|
|
# Adjust h edge with play
|
|
|
|
self.edges["f"].settings.setValues(t, False, edge_width=self.edges["f"].settings.edge_width + p)
|
|
|
|
|
|
|
|
for i in range(2):
|
|
|
|
d = i * 2 * (t+p)
|
2020-08-04 19:31:51 +02:00
|
|
|
height = [hi, h][i]
|
2019-01-12 23:16:11 +01:00
|
|
|
with self.saved_context():
|
2020-08-04 19:31:51 +02:00
|
|
|
self.rectangularWall(x+d, height, "fFeF", move="right")
|
|
|
|
self.rectangularWall(y+d, height, "ffef", move="right")
|
|
|
|
self.rectangularWall(x+d, height, "fFeF", move="right")
|
|
|
|
self.rectangularWall(y+d, height, "ffef", move="right")
|
|
|
|
self.rectangularWall(y, height, "ffef", move="up only")
|
2018-08-15 20:23:23 +02:00
|
|
|
|
|
|
|
self.rectangularWall(x, y, "hhhh", bedBolts=None, move="right")
|
|
|
|
self.rectangularWall(x+d, y+d, "FFFF", bedBolts=None, move="right")
|
|
|
|
|