From c2fa8c85cfd3d1752a53c0aeb7bcf6594b10aa19 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Wed, 22 Mar 2017 22:00:22 +0100 Subject: [PATCH] Pulley: Add insideout param This allows using timing belts as strainwaves in harmonic drives. --- boxes/generators/pulley.py | 5 ++++- boxes/pulley.py | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/boxes/generators/pulley.py b/boxes/generators/pulley.py index c527670..490dc02 100644 --- a/boxes/generators/pulley.py +++ b/boxes/generators/pulley.py @@ -38,6 +38,9 @@ class Pulley(Boxes): self.argparser.add_argument( "--axle", action="store", type=float, default=5, help="diameter of the axle") + self.argparser.add_argument( + "--insideout", action="store", type=BoolArg(), default=False, + help="create a ring gear with the belt being pushed against from within") self.argparser.add_argument( "--top", action="store", type=float, default=0, help="overlap of top rim (zero for none)") @@ -77,7 +80,7 @@ class Pulley(Boxes): self.axle, move="right") for i in range(int(math.ceil(self.h / self.thickness))): - self.pulley(self.teeth, self.profile, r_axle=self.axle / 2.0, move="right") + self.pulley(self.teeth, self.profile, insideout=self.insideout, r_axle=self.axle / 2.0, move="right") self.close() diff --git a/boxes/pulley.py b/boxes/pulley.py index f59651b..e1b9000 100644 --- a/boxes/pulley.py +++ b/boxes/pulley.py @@ -83,7 +83,7 @@ class Pulley: @classmethod def getProfiles(cls): - return list(cls.teeth.keys()) + return list(sorted(cls.teeth.keys())) def drawPoints(self, lines, kerfdir=1): if kerfdir != 0: @@ -103,7 +103,8 @@ class Pulley: return tooth_spacing(teeth, *self.spacing[profile][1:]) - def __call__(self, teeth, profile, move="", r_axle=None, callback=None): + def __call__(self, teeth, profile, insideout=False, r_axle=None, + callback=None, move=""): # ******************************** # ** Scaling tooth for good fit ** @@ -122,7 +123,11 @@ class Pulley: tooth_width_scale = (tooth_width + additional_tooth_width) / tooth_width tooth_depth_scale = ((tooth_depth + additional_tooth_depth) / tooth_depth) - total_width = pulley_OD + if insideout: + pulley_OD += 2*tooth_depth * tooth_depth_scale + tooth_depth_scale *= -1 + + total_width = max(pulley_OD, 2*r_axle) if self.boxes.move(total_width, total_width, move, before=True): return @@ -131,7 +136,10 @@ class Pulley: self.boxes.cc(callback, None, 0.0, 0.0) if r_axle: - self.boxes.hole(0, 0, r_axle) + if insideout: + self.boxes.circle(0, 0, r_axle) + else: + self.boxes.hole(0, 0, r_axle) points = [] for i in range(teeth): @@ -140,5 +148,5 @@ class Pulley: m = mmul(m, rotm(i * 2 * pi / teeth)) points.extend((vtransl(pt, m) for pt in self.teeth[profile][1:-1])) - self.drawPoints(points) + self.drawPoints(points, kerfdir=-1 if insideout else 1) self.boxes.move(total_width, total_width, move)