New GearBox generator

This commit is contained in:
Florian Festi 2016-07-16 15:32:06 +02:00
parent 113783ce32
commit a7728d8e32
2 changed files with 96 additions and 1 deletions

View File

@ -0,0 +1,94 @@
#!/usr/bin/env python3
# Copyright (C) 2013-2016 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 GearBox(Boxes):
"""Gearbox with multiple identical stages"""
def __init__(self):
Boxes.__init__(self)
self.argparser.add_argument(
"--teeth1", action="store", type=int, default=8,
help="number of teeth on ingoing shaft")
self.argparser.add_argument(
"--teeth2", action="store", type=int, default=20,
help="number of teeth on outgoing shaft")
self.argparser.add_argument(
"--modulus", action="store", type=float, default=3,
help="modulus of thetth in mm")
self.argparser.add_argument(
"--shaft", action="store", type=float, default=6.,
help="diameter of the shaft")
self.argparser.add_argument(
"--stages", action="store", type=int, default=4,
help="number of stages in the gear reduction")
def render(self):
# Initialize canvas
self.open()
if self.teeth2 < self.teeth1:
self.teeth2, self.teeth1 = self.teeth1, self.teeth2
pitch1, size1, xxx = self.gears.sizes(teeth=self.teeth1,
dimension=self.modulus)
pitch2, size2, xxx = self.gears.sizes(teeth=self.teeth2,
dimension=self.modulus)
t = self.thickness
x = 1.1*t*self.stages
y = size1 + size2
h = max(size1, size2) + t
b = "F"
t = "e" # prepare for close box
mh = self.shaft
# render your parts here
y1 = y/2-(pitch1+pitch2)+pitch1
y2 = y/2+(pitch1+pitch2)-pitch2
def sideCB():
self.hole(y1, h/2, mh/2)
self.hole(y2, h/2, mh/2)
self.moveTo(self.thickness, self.thickness)
self.rectangularWall(y, h, [b, "f", t, "f"], callback=[sideCB], move="right")
self.rectangularWall(x, h, [b, "F", t, "F"], move="up")
self.rectangularWall(x, h, [b, "F", t, "F"])
self.rectangularWall(y, h, [b, "f", t, "f"], callback=[sideCB], move="left")
self.rectangularWall(x, h, [b, "F", t, "F"], move="up only")
self.rectangularWall(x, y, "ffff", move="up")
for i in range(self.stages-1):
self.gears(teeth=self.teeth2, dimension=self.modulus,
mount_hole=mh, move="up")
self.gears(teeth=self.teeth2, dimension=self.modulus,
mount_hole=mh, move="right")
for i in range(self.stages):
self.gears(teeth=self.teeth1, dimension=self.modulus,
mount_hole=mh, move="down")
self.close()
def main():
b = Box()
b.parseArgs()
b.render()
if __name__ == '__main__':
main()

View File

@ -27,7 +27,7 @@ except ImportError:
from boxes.generators import box, box2, box3, drillbox
from boxes.generators import flexbox, flexbox2, flexbox3, flexbox4
from boxes.generators import flexbox, flexbox2, flexbox3, flexbox4, gearbox
from boxes.generators import flextest, flextest2, folder, pulley
from boxes.generators import magazinefile, trayinsert, traylayout, typetray, silverwarebox
@ -88,6 +88,7 @@ class BServer:
"FlexTest": flextest.FlexTest(),
"FlexTest2": flextest2.FlexTest(),
"Folder": folder.Folder(),
"GearBox" : gearbox.GearBox(),
"MagazinFile" : magazinefile.Box(),
"TrayInsert" : trayinsert.TrayInsert(),
"Pulley" : pulley.Pulley(),