New generator: NemaMount

This commit is contained in:
Florian Festi 2017-11-19 18:10:59 +01:00
parent 46c4960edc
commit 642212d2ce
1 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,53 @@
#!/usr/bin/env python3
# Copyright (C) 2013-2017 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 NemaMount(Boxes):
"""Mounting braket for a Nema motor"""
ui_group = "Part"
def __init__(self):
Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.argparser.add_argument(
"--size", action="store", type=int, default=8,
choices=list(sorted(self.nema_sizes.keys())),
help="Nema size of the motor")
def render(self):
motor, flange, holes, screws = self.nema_sizes.get(
self.size, self.nema_sizes[8])
t = self.thickness
x = y = h = motor + 2*t
self.open()
self.rectangularWall(x, h, "FFeF", callback=[
lambda:self.rectangularHole((x-holes)/2, y/2, screws, holes,
screws/2),
None,
lambda:self.rectangularHole((x-holes)/2, y/2, screws, holes,
screws/2)],
move="right")
self.rectangularWall(x, y, "ffef", callback=[
lambda: self.NEMA(self.size, x/2, y/2)], move="right")
self.rectangularTriangle(x, h, "fFe", num=2)
self.close()