2016-07-11 23:01:57 +02:00
|
|
|
#!/usr/bin/env python3
|
2014-03-16 18:26:12 +01:00
|
|
|
# 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/>.
|
2014-03-15 15:03:38 +01:00
|
|
|
|
|
|
|
from boxes import *
|
2016-03-23 09:11:51 +01:00
|
|
|
from boxes.edges import Bolts
|
2014-03-15 15:03:38 +01:00
|
|
|
import inspect
|
|
|
|
|
2016-07-31 14:15:06 +02:00
|
|
|
class Box2(Boxes):
|
2016-06-30 11:50:01 +02:00
|
|
|
"""Box various options for different stypes and lids"""
|
2016-03-08 21:53:29 +01:00
|
|
|
|
2016-03-03 13:27:22 +01:00
|
|
|
def __init__(self):
|
|
|
|
Boxes.__init__(self)
|
2016-11-01 14:03:07 +01:00
|
|
|
self.addSettingsArgs(edges.FingerJointSettings, finger=3, space=3)
|
|
|
|
self.addSettingsArgs(edges.StackableSettings)
|
|
|
|
self.addSettingsArgs(edges.HingeSettings)
|
|
|
|
self.addSettingsArgs(edges.LidSettings)
|
|
|
|
self.addSettingsArgs(edges.ClickSettings)
|
|
|
|
self.addSettingsArgs(edges.FlexSettings)
|
2016-04-09 11:47:12 +02:00
|
|
|
self.buildArgParser("top_edge", "bottom_edge", "x", "y", "h")
|
2016-04-19 21:02:56 +02:00
|
|
|
self.argparser.add_argument(
|
|
|
|
"--chestlid", action="store", type=bool, default=False,
|
|
|
|
help="add chest lid (needs hinges)")
|
|
|
|
self.angle = 0
|
2014-03-15 15:03:38 +01:00
|
|
|
|
2016-04-19 21:02:56 +02:00
|
|
|
def getR(self):
|
|
|
|
x, y, h, angle = self.x, self.y, self.h, self.angle
|
|
|
|
t = self.thickness
|
|
|
|
d = x - 2*math.sin(math.radians(angle)) * (3*t)
|
|
|
|
|
|
|
|
r = d / 2.0 / math.cos(math.radians(angle))
|
|
|
|
return r
|
|
|
|
|
|
|
|
def side(self, move=""):
|
|
|
|
x, y, h, angle = self.x, self.y, self.h, self.angle
|
|
|
|
t = self.thickness
|
|
|
|
r = self.getR()
|
2016-07-27 22:19:32 +02:00
|
|
|
if self.move(x+2*t, 0.5*x+3*t, move, True):
|
2016-04-19 21:02:56 +02:00
|
|
|
return
|
|
|
|
|
2016-07-27 22:19:32 +02:00
|
|
|
self.moveTo(t, 0)
|
2016-04-19 21:02:56 +02:00
|
|
|
self.edge(x)
|
|
|
|
self.corner(90+angle)
|
2016-06-30 13:59:13 +02:00
|
|
|
self.edges["a"](3*t)
|
2016-04-19 21:02:56 +02:00
|
|
|
self.corner(180-2*angle, r)
|
2016-06-30 13:59:13 +02:00
|
|
|
self.edges["a"](3*t)
|
2016-04-19 21:02:56 +02:00
|
|
|
self.corner(90+angle)
|
|
|
|
|
2016-07-27 22:19:32 +02:00
|
|
|
self.move(x+2*t, 0.5*x+3*t, move, False)
|
2016-04-19 21:02:56 +02:00
|
|
|
|
|
|
|
def top(self):
|
2016-07-27 22:19:32 +02:00
|
|
|
# XXX move param
|
2016-04-19 21:02:56 +02:00
|
|
|
x, y, h = self.x, self.y, self.h
|
|
|
|
t = self.thickness
|
|
|
|
angle = 30
|
|
|
|
|
|
|
|
l = math.radians(180-2*angle) * self.getR()
|
|
|
|
|
2016-06-30 13:59:13 +02:00
|
|
|
self.edges["A"](3*t)
|
2016-04-19 21:02:56 +02:00
|
|
|
self.edges["X"](l, y+2*t)
|
2016-06-30 13:59:13 +02:00
|
|
|
self.edges["A"](3*t)
|
2016-04-19 21:02:56 +02:00
|
|
|
self.corner(90)
|
|
|
|
self.edge(y+2*t)
|
|
|
|
self.corner(90)
|
2016-06-30 13:59:13 +02:00
|
|
|
self.edges["A"](3*t)
|
2016-04-19 21:02:56 +02:00
|
|
|
self.edge(l)
|
2016-06-30 13:59:13 +02:00
|
|
|
self.edges["A"](3*t)
|
2016-04-19 21:02:56 +02:00
|
|
|
self.corner(90)
|
|
|
|
self.edge(y+2*t)
|
|
|
|
self.corner(90)
|
|
|
|
|
2014-03-15 15:03:38 +01:00
|
|
|
def render(self):
|
|
|
|
x, y, h = self.x, self.y, self.h
|
2016-04-09 11:47:12 +02:00
|
|
|
|
2016-06-07 20:20:35 +02:00
|
|
|
self.open()
|
2016-04-19 21:02:56 +02:00
|
|
|
# generate g,G finger joints with default settings
|
|
|
|
s = edges.FingerJointSettings(self.thickness)
|
|
|
|
g = edges.FingerJointEdge(self, s)
|
2016-06-30 13:59:13 +02:00
|
|
|
g.char = 'a'
|
2016-04-19 21:02:56 +02:00
|
|
|
self.addPart(g)
|
|
|
|
G = edges.FingerJointEdgeCounterPart(self, s)
|
2016-06-30 13:59:13 +02:00
|
|
|
G.char = 'A'
|
2016-04-19 21:02:56 +02:00
|
|
|
self.addPart(G)
|
2014-03-15 15:03:38 +01:00
|
|
|
|
2016-04-09 11:47:12 +02:00
|
|
|
b = self.edges.get(self.bottom_edge, self.edges["F"])
|
2016-06-28 17:40:23 +02:00
|
|
|
t1 = t2 = t3 = t4 = self.edges.get(self.top_edge, self.edges["e"])
|
|
|
|
|
|
|
|
if t1.char == "i":
|
|
|
|
t2 = t4 = "e"
|
|
|
|
t3 = "j"
|
2016-06-30 11:14:26 +02:00
|
|
|
elif t1.char == "k":
|
|
|
|
t2 = t4 = "e"
|
2016-10-27 21:33:29 +02:00
|
|
|
elif t1.char == "L":
|
|
|
|
t1 = "M"
|
|
|
|
t2 = "e"
|
|
|
|
t3 = "N"
|
2016-07-03 09:55:59 +02:00
|
|
|
|
|
|
|
self.edges["k"].settings.setValues(self.thickness, outset=True)
|
2016-04-19 21:02:56 +02:00
|
|
|
|
2016-03-23 09:11:51 +01:00
|
|
|
d2 = Bolts(2)
|
|
|
|
d3 = Bolts(3)
|
2014-03-15 15:03:38 +01:00
|
|
|
|
|
|
|
d2 = d3 = None
|
|
|
|
|
2016-06-28 17:40:23 +02:00
|
|
|
self.rectangularWall(y, h, [b, "f", t2, "f"],
|
|
|
|
bedBolts=[d3], move="right")
|
|
|
|
self.rectangularWall(x, h, [b, "F", t1, "F"],
|
|
|
|
bedBolts=[d2], move="up")
|
|
|
|
self.rectangularWall(x, h, [b, "F", t3, "F"],
|
|
|
|
bedBolts=[d2])
|
|
|
|
self.rectangularWall(y, h, [b, "f", t4, "f"],
|
|
|
|
bedBolts=[d3], move="left")
|
|
|
|
self.rectangularWall(x, h, [b, "F", t3, "F"],
|
|
|
|
bedBolts=[d2], move="up only")
|
2014-03-15 15:03:38 +01:00
|
|
|
|
2016-05-03 23:01:40 +02:00
|
|
|
self.rectangularWall(x, y, "ffff", bedBolts=[d2, d3, d2, d3], move="right")
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-05-03 23:01:40 +02:00
|
|
|
if self.top_edge == "c":
|
|
|
|
self.rectangularWall(x, y, "CCCC", bedBolts=[d2, d3, d2, d3], move="up")
|
2016-10-02 20:47:02 +02:00
|
|
|
elif self.top_edge == "f":
|
|
|
|
self.rectangularWall(x, y, "FFFF", move="up")
|
2016-10-27 21:33:29 +02:00
|
|
|
elif self.top_edge == "L":
|
|
|
|
self.rectangularWall(x, y, "nlmE", move="up")
|
2016-06-28 17:40:23 +02:00
|
|
|
elif self.top_edge == "i":
|
2016-06-30 11:14:26 +02:00
|
|
|
self.rectangularWall(x, y, "IEJe", move="up")
|
|
|
|
elif self.top_edge == "k":
|
|
|
|
lx = x/2.0-0.1*self.thickness
|
2016-07-03 09:55:59 +02:00
|
|
|
self.edges['k'].settings.setValues(self.thickness, grip_length=5)
|
2016-06-30 11:14:26 +02:00
|
|
|
self.rectangularWall(lx, y, "IeJe", move="right")
|
|
|
|
self.rectangularWall(lx, y, "IeJe", move="up")
|
2016-04-19 21:02:56 +02:00
|
|
|
else:
|
|
|
|
self.rectangularWall(x, y, "CCCC", bedBolts=[d2, d3, d2, d3], move="up only")
|
|
|
|
|
|
|
|
if self.chestlid:
|
|
|
|
self.side()
|
|
|
|
self.side(move="left up")
|
|
|
|
self.top()
|
2014-03-15 15:03:38 +01:00
|
|
|
|
2014-03-21 21:08:54 +01:00
|
|
|
self.close()
|
2014-03-15 15:03:38 +01:00
|
|
|
|
2016-03-23 22:05:06 +01:00
|
|
|
def main():
|
2016-07-31 14:15:06 +02:00
|
|
|
b = Box2()
|
2016-03-03 13:27:22 +01:00
|
|
|
b.parseArgs()
|
|
|
|
b.render()
|
2016-03-23 22:05:06 +01:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|