Add outside parameter to some generators

This commit is contained in:
Florian Festi 2016-07-09 22:52:48 +02:00
parent 261a6999f4
commit 3f97d7ad77
10 changed files with 67 additions and 12 deletions

View File

@ -20,17 +20,24 @@ class Box(Boxes):
"""Fully closed box"""
def __init__(self):
Boxes.__init__(self)
self.buildArgParser("x", "y", "h")
self.buildArgParser("x", "y", "h", "outside")
self.argparser.set_defaults(
fingerjointfinger=3.0,
fingerjointspace=3.0
)
def render(self):
x, y, h = self.x, self.y, self.h
t = self.thickness
self.open()
x, y, h = self.x, self.y, self.h
if self.outside:
x = self.adjustSize(x)
y = self.adjustSize(y)
h = self.adjustSize(h)
t = self.thickness
d2 = [edges.Bolts(2)]
d3 = [edges.Bolts(3)]

View File

@ -20,7 +20,7 @@ class Box(Boxes):
"""Box with just 3 walls"""
def __init__(self):
Boxes.__init__(self)
self.buildArgParser("x", "y", "h")
self.buildArgParser("x", "y", "h", "outside")
self.argparser.set_defaults(
fingerjointfinger=3.0,
fingerjointspace=3.0
@ -30,6 +30,11 @@ class Box(Boxes):
x, y, h = self.x, self.y, self.h
t = self.thickness
if self.outside:
x = self.adjustSize(x)
y = self.adjustSize(y, False)
h = self.adjustSize(h, False)
self.open()
d2 = [edges.Bolts(2)]

View File

@ -21,7 +21,7 @@ class FlexBox(boxes.Boxes):
"""Box with living hinge and round corners"""
def __init__(self):
boxes.Boxes.__init__(self)
self.buildArgParser("x", "y", "h")
self.buildArgParser("x", "y", "h", "outside")
self.argparser.add_argument(
"--radius", action="store", type=float, default=15,
help="Radius of the latch in mm")
@ -77,6 +77,12 @@ class FlexBox(boxes.Boxes):
self.corner(90)
def render(self):
if self.outside:
self.x = self.adjustSize(self.x)
self.y = self.adjustSize(self.y)
self.h = self.adjustSize(self.h)
x, y, h = self.x, self.y, self.h
self.latchsize = 8 * self.thickness
r = self.radius or min(x, y-self.latchsize)/2.0

View File

@ -21,7 +21,7 @@ class FlexBox(Boxes):
"""Box with living hinge and top corners rounded"""
def __init__(self):
Boxes.__init__(self)
self.buildArgParser("x", "y", "h")
self.buildArgParser("x", "y", "h", "outside")
self.argparser.add_argument(
"--radius", action="store", type=float, default=15,
help="Radius of the corners in mm")
@ -67,6 +67,11 @@ class FlexBox(Boxes):
self.corner(90)
def render(self):
if self.outside:
self.x = self.adjustSize(self.x)
self.y = self.adjustSize(self.y)
self.h = self.adjustSize(self.h)
self.latchsize = 8*self.thickness
self.radius = self.radius or min(self.x/2.0, self.y-self.latchsize)
self.radius = min(self.radius, self.x/2.0)

View File

@ -21,7 +21,7 @@ class FlexBox(Boxes):
"""Box with living hinge"""
def __init__(self):
Boxes.__init__(self)
self.buildArgParser("x", "y")
self.buildArgParser("x", "y", "outside")
self.argparser.add_argument(
"--z", action="store", type=float, default=100.0,
help="height of the box")
@ -99,6 +99,11 @@ class FlexBox(Boxes):
self.edge(x+2*t)
def render(self):
if self.outside:
self.x = self.adjustSize(self.x)
self.y = self.adjustSize(self.y)
self.z = self.adjustSize(self.z)
x, y, z, d, h = self.x, self.y, self.z, self.d, self.h
r = self.radius = self.radius or min(x, y)/2.0
thickness = self.thickness

View File

@ -21,7 +21,7 @@ class FlexBox(Boxes):
"""Box with living hinge and left corners rounded"""
def __init__(self):
Boxes.__init__(self)
self.buildArgParser("x", "y", "h")
self.buildArgParser("x", "y", "h", "outside")
self.argparser.add_argument(
"--radius", action="store", type=float, default=15,
help="Radius of the corners in mm")
@ -69,6 +69,11 @@ class FlexBox(Boxes):
self.corner(90)
def render(self):
if self.outside:
self.x = self.adjustSize(self.x)
self.y = self.adjustSize(self.y)
self.h = self.adjustSize(self.h)
self.c4 = c4 = math.pi * self.radius * 0.5
self.latchsize = 8*self.thickness
self.radius = self.radius or min(self.x/2.0, self.y-self.latchsize)

View File

@ -20,7 +20,7 @@ class Box(Boxes):
"""Open magazine file"""
def __init__(self):
Boxes.__init__(self)
self.buildArgParser("x", "y", "h", "hi")
self.buildArgParser("x", "y", "h", "hi", "outside")
self.argparser.set_defaults(
fingerjointfinger=2.0,
fingerjointspace=2.0
@ -60,6 +60,11 @@ class Box(Boxes):
def render(self):
if self.outside:
self.x = self.adjustSize(self.x)
self.y = self.adjustSize(self.y)
self.h = self.adjustSize(self.h, e2=False)
x, y, h, = self.x, self.y, self.h
self.hi = hi = self.hi or (h / 2.0)
t = self.thickness

View File

@ -20,9 +20,13 @@ class TrayInsert(Boxes):
"""Tray insert without floor and outer walls - allows only continuous walls"""
def __init__(self):
Boxes.__init__(self)
self.buildArgParser("sx", "sy", "h")
self.buildArgParser("sx", "sy", "h", "outside")
def render(self):
if self.outside:
self.sx = self.adjustSize(self.sx, False, False)
self.sy = self.adjustSize(self.sy, False, False)
x = sum(self.sx) + self.thickness * (len(self.sx)-1)
y = sum(self.sy) + self.thickness * (len(self.sy)-1)
h = self.h

View File

@ -22,7 +22,7 @@ class Layout(Boxes):
"""Generate a typetray from a layout file"""
def __init__(self, input=None, webargs=False):
Boxes.__init__(self)
self.buildArgParser("h", "hi")
self.buildArgParser("h", "hi", "outside")
if not webargs:
self.argparser.add_argument(
"--input", action="store", type=argparse.FileType('r'),
@ -91,6 +91,12 @@ class Layout(Boxes):
edge(length)
def render(self):
if self.outside:
self.x = self.adjustSize(self.x)
self.y = self.adjustSize(self.y)
self.h = self.adjustSize(self.h, e2=False)
if self.hi:
self.hi = self.adjustSize(self.hi, e2=False)
self.hi = hi = self.hi or self.h

View File

@ -20,7 +20,7 @@ class TypeTray(Boxes):
"""Type tray - allows only continuous walls"""
def __init__(self):
Boxes.__init__(self)
self.buildArgParser("sx", "sy", "h", "hi")
self.buildArgParser("sx", "sy", "h", "hi", "outside")
self.argparser.add_argument(
"--gripheight", action="store", type=float, default=30,
dest="gh", help="height of the grip hole in mm")
@ -72,6 +72,13 @@ class TypeTray(Boxes):
self.rectangularHole(x/2.0, self.gh*1.5, self.gw, self.gh, r)
def render(self):
if self.outside:
self.sx = self.adjustSize(self.sx)
self.sy = self.adjustSize(self.sy)
self.h = self.adjustSize(self.h, e2=False)
if self.hi:
self.hi = self.adjustSize(self.hi, e2=False)
x = sum(self.sx) + self.thickness * (len(self.sx)-1)
y = sum(self.sy) + self.thickness * (len(self.sy)-1)
h = self.h