Add nema_mount default parameter

Make nema_sizes available outside of NEMA() function.
This whole stuff should probably move into it's own file/class at some point
This commit is contained in:
Florian Festi 2017-03-29 07:38:10 +02:00
parent 53cbed768b
commit c7490155f7
1 changed files with 20 additions and 13 deletions

View File

@ -327,6 +327,12 @@ class Boxes:
self.argparser.add_argument(
"--outside", action="store", type=boolarg, default=default,
help="treat sizes as outside measurements that include the walls")
elif arg == "nema_mount":
if default is None: default = 23
self.argparser.add_argument(
"--nema_mount", action="store",
type=int, choices=list(sorted(self.nema_sizes.keys())),
default=default, help="NEMA size of motor")
else:
raise ValueError("No default for argument", arg)
@ -980,6 +986,19 @@ class Boxes:
self.ctx.scale(1, -1)
self.ctx.show_text(text)
nema_sizes = {
# motor,flange, holes, screws
8: (20.3, 16, 15.4, 3),
11: (28.2, 22, 23, 4),
14: (35.2, 22, 26, 4),
16: (39.2, 22, 31, 4),
17: (42.2, 22, 31, 4),
23: (56.4, 38.1, 47.1, 5.2),
24: (60, 36, 49.8, 5.1),
34: (86.3, 73, 69.8, 6.6),
42: (110, 55.5, 89, 8.5),
}
@restore
def NEMA(self, size, x=0, y=0, angle=0):
"""Draw holes for mounting a NEMA stepper motor
@ -990,19 +1009,7 @@ class Boxes:
:param angle: (Default value = 0)
"""
nema = {
# motor,flange, holes, screws
8: (20.3, 16, 15.4, 3),
11: (28.2, 22, 23, 4),
14: (35.2, 22, 26, 4),
16: (39.2, 22, 31, 4),
17: (42.2, 22, 31, 4),
23: (56.4, 38.1, 47.1, 5.2),
24: (60, 36, 49.8, 5.1),
34: (86.3, 73, 69.8, 6.6),
42: (110, 55.5, 89, 8.5),
}
width, flange, holedistance, diameter = nema[size]
width, flange, holedistance, diameter = self.nema_sizes[size]
self.moveTo(x, y, angle)
if self.debug:
self.rectangularHole(0, 0, width, width)