Add params for edge settings to all generators

This commit is contained in:
Florian Festi 2016-11-01 14:03:07 +01:00
parent 7baafebaea
commit 0cde4a71e6
20 changed files with 43 additions and 37 deletions

View File

@ -23,6 +23,15 @@ class BOX(Boxes): # change class name here and below
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
# Uncomment the settings for the edge types you use
# self.addSettingsArgs(edges.FingerJointSettings)
# self.addSettingsArgs(edges.StackableSettings)
# self.addSettingsArgs(edges.HingeSettings)
# self.addSettingsArgs(edges.LidSettings)
# self.addSettingsArgs(edges.ClickSettings)
# self.addSettingsArgs(edges.FlexSettings)
# remove cli params you do not need # remove cli params you do not need
self.buildArgParser("x", "sx", "y", "sy", "h", "hi") self.buildArgParser("x", "sx", "y", "sy", "h", "hi")
# Add non default cli params if needed (see argparse std lib) # Add non default cli params if needed (see argparse std lib)

View File

@ -21,6 +21,7 @@ class Arcade(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.argparser.add_argument( self.argparser.add_argument(
"--width", action="store", type=float, default=450.0, "--width", action="store", type=float, default=450.0,
help="inner width of the console") help="inner width of the console")

View File

@ -22,11 +22,8 @@ class Box(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings, finger=3.0, space=3.0)
self.buildArgParser("x", "y", "h", "outside") self.buildArgParser("x", "y", "h", "outside")
self.argparser.set_defaults(
fingerjointfinger=3.0,
fingerjointspace=3.0
)
def render(self): def render(self):
self.open() self.open()

View File

@ -23,15 +23,17 @@ class Box2(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
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)
self.buildArgParser("top_edge", "bottom_edge", "x", "y", "h") self.buildArgParser("top_edge", "bottom_edge", "x", "y", "h")
self.argparser.add_argument( self.argparser.add_argument(
"--chestlid", action="store", type=bool, default=False, "--chestlid", action="store", type=bool, default=False,
help="add chest lid (needs hinges)") help="add chest lid (needs hinges)")
self.angle = 0 self.angle = 0
self.argparser.set_defaults(
fingerjointfinger=3.0,
fingerjointspace=3.0
)
def getR(self): def getR(self):
x, y, h, angle = self.x, self.y, self.h, self.angle x, y, h, angle = self.x, self.y, self.h, self.angle

View File

@ -22,10 +22,7 @@ class Box3(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.buildArgParser("x", "y", "h", "outside") self.buildArgParser("x", "y", "h", "outside")
self.argparser.set_defaults( self.addSettingsArgs(edges.FingerJointSettings, finger=3.0, space=3.0)
fingerjointfinger=3.0,
fingerjointspace=3.0
)
def render(self): def render(self):
x, y, h = self.x, self.y, self.h x, y, h = self.x, self.y, self.h

View File

@ -22,6 +22,7 @@ class Castle(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(boxes.edges.FingerJointSettings)
def render(self, t_x=70, t_h=250, w1_x=300, w1_h=120, w2_x=100, w2_h=120): def render(self, t_x=70, t_h=250, w1_x=300, w1_h=120, w2_x=100, w2_h=120):
self.open() self.open()

View File

@ -23,6 +23,7 @@ in 0.5mm steps, 3 holes each size"""
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.x, self.y, self.h = 120, 240, 60 self.x, self.y, self.h = 120, 240, 60
def holesx(self): def holesx(self):

View File

@ -23,6 +23,8 @@ class FlexBox(boxes.Boxes):
def __init__(self): def __init__(self):
boxes.Boxes.__init__(self) boxes.Boxes.__init__(self)
self.addSettingsArgs(boxes.edges.FingerJointSettings)
self.addSettingsArgs(boxes.edges.FlexSettings)
self.buildArgParser("x", "y", "h", "outside") self.buildArgParser("x", "y", "h", "outside")
self.argparser.add_argument( self.argparser.add_argument(
"--radius", action="store", type=float, default=15, "--radius", action="store", type=float, default=15,

View File

@ -23,6 +23,8 @@ class FlexBox2(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.addSettingsArgs(edges.FlexSettings)
self.buildArgParser("x", "y", "h", "outside") self.buildArgParser("x", "y", "h", "outside")
self.argparser.add_argument( self.argparser.add_argument(
"--radius", action="store", type=float, default=15, "--radius", action="store", type=float, default=15,

View File

@ -23,6 +23,8 @@ class FlexBox3(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.addSettingsArgs(edges.FlexSettings)
self.buildArgParser("x", "y", "outside") self.buildArgParser("x", "y", "outside")
self.argparser.add_argument( self.argparser.add_argument(
"--z", action="store", type=float, default=100.0, "--z", action="store", type=float, default=100.0,

View File

@ -23,6 +23,8 @@ class FlexBox4(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.addSettingsArgs(edges.FlexSettings)
self.buildArgParser("x", "y", "h", "outside") self.buildArgParser("x", "y", "h", "outside")
self.argparser.add_argument( self.argparser.add_argument(
"--radius", action="store", type=float, default=15, "--radius", action="store", type=float, default=15,

View File

@ -22,25 +22,13 @@ class FlexTest(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FlexSettings)
self.buildArgParser("x", "y") self.buildArgParser("x", "y")
self.argparser.add_argument(
"--fd", action="store", type=float, default=0.5,
help="distance of flex cuts in multiples of thickness")
self.argparser.add_argument(
"--fc", action="store", type=float, default=1.0,
help="connections of flex cuts in multiples of thickness")
self.argparser.add_argument(
"--fw", action="store", type=float, default=5.0,
help="width of flex cuts in multiples of thickness")
def render(self): def render(self):
x, y = self.x, self.y x, y = self.x, self.y
self.open() self.open()
self.edges["X"].settings.setValues(
self.thickness, relative=True,
distance=self.fd, connection=self.fc, width=self.fw)
self.moveTo(5, 5) self.moveTo(5, 5)
self.edge(10) self.edge(10)
self.edges["X"](x, y) self.edges["X"](x, y)

View File

@ -23,6 +23,7 @@ class Folder(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.buildArgParser("x", "y", "h") self.buildArgParser("x", "y", "h")
self.argparser.add_argument( self.argparser.add_argument(
"--r", action="store", type=float, default=10.0, "--r", action="store", type=float, default=10.0,

View File

@ -22,6 +22,7 @@ class GearBox(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.argparser.add_argument( self.argparser.add_argument(
"--teeth1", action="store", type=int, default=8, "--teeth1", action="store", type=int, default=8,
help="number of teeth on ingoing shaft") help="number of teeth on ingoing shaft")

View File

@ -63,6 +63,7 @@ class Lamp(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
def side(self, y, h): def side(self, y, h):
return return

View File

@ -23,10 +23,7 @@ class MagazinFile(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.buildArgParser("x", "y", "h", "hi", "outside") self.buildArgParser("x", "y", "h", "hi", "outside")
self.argparser.set_defaults( self.addSettingsArgs(edges.FingerJointSettings, finger=2.0, space=2.0)
fingerjointfinger=2.0,
fingerjointspace=2.0
)
def side(self, w, h, hi): def side(self, w, h, hi):
r = min(h - hi, w) / 2.0 r = min(h - hi, w) / 2.0

View File

@ -24,6 +24,9 @@ class Printer(Boxes):
def __init__(self, r=250, h=400, d_c=100): def __init__(self, r=250, h=400, d_c=100):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.r = r self.r = r
self.h = h self.h = h
self.d_c = d_c self.d_c = d_c

View File

@ -85,9 +85,9 @@ class Rotary(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
# remove cli params you do not need
# self.buildArgParser("x", "sx", "y", "sy", "h", "hi") self.addSettingsArgs(edges.FingerJointSettings)
# Add non default cli params if needed (see argparse std lib)
self.argparser.add_argument( self.argparser.add_argument(
"--diameter", action="store", type=float, default=72., "--diameter", action="store", type=float, default=72.,
help="outer diameter of the wheels (including O rings)") help="outer diameter of the wheels (including O rings)")

View File

@ -26,6 +26,7 @@ class Layout(Boxes):
def __init__(self, input=None, webargs=False): def __init__(self, input=None, webargs=False):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(boxes.edges.FingerJointSettings)
self.buildArgParser("h", "hi", "outside") self.buildArgParser("h", "hi", "outside")
if not webargs: if not webargs:
self.argparser.add_argument( self.argparser.add_argument(
@ -404,6 +405,7 @@ class TrayLayout2(Layout):
def __init__(self, input=None): def __init__(self, input=None):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(boxes.edges.FingerJointSettings)
self.buildArgParser("h", "hi", "outside") self.buildArgParser("h", "hi", "outside")
self.argparser.add_argument( self.argparser.add_argument(
"--layout", action="store", type=str) "--layout", action="store", type=str)

View File

@ -23,17 +23,14 @@ class TypeTray(Boxes):
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.buildArgParser("sx", "sy", "h", "hi", "outside") self.buildArgParser("sx", "sy", "h", "hi", "outside")
self.addSettingsArgs(edges.FingerJointSettings, finger=3.0, space=3.0,
surroundingspaces=0.5)
self.argparser.add_argument( self.argparser.add_argument(
"--gripheight", action="store", type=float, default=30, "--gripheight", action="store", type=float, default=30,
dest="gh", help="height of the grip hole in mm") dest="gh", help="height of the grip hole in mm")
self.argparser.add_argument( self.argparser.add_argument(
"--gripwidth", action="store", type=float, default=70, "--gripwidth", action="store", type=float, default=70,
dest="gw", help="width of th grip hole in mm (zero for no hole)") dest="gw", help="width of th grip hole in mm (zero for no hole)")
self.argparser.set_defaults(
fingerjointfinger=3.0,
fingerjointspace=3.0,
fingerjointsurrounding=0.5,
)
def xSlots(self): def xSlots(self):
posx = -0.5 * self.thickness posx = -0.5 * self.thickness