From 01312788bba2ec3623c889743f8b77344db37a54 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Wed, 13 Jul 2016 13:35:57 +0200 Subject: [PATCH] Make Pulley a part with callback and move params --- boxes/pulley.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/boxes/pulley.py b/boxes/pulley.py index c1a51c3..8dec727 100644 --- a/boxes/pulley.py +++ b/boxes/pulley.py @@ -84,7 +84,7 @@ class Pulley: self.boxes.ctx.line_to(*lines[0]) self.boxes.ctx.restore() - def __call__(self, teeth, profile): + def __call__(self, teeth, profile, move="", r_axle=None, callback=None): # ******************************** # ** Scaling tooth for good fit ** @@ -106,6 +106,14 @@ 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 + 2 * self.boxes.spacing + if self.boxes.move(total_width, total_width, move, before=True): + return + self.boxes.ctx.save() + self.boxes.moveTo(total_width/2, total_width/2) + self.boxes.cc(callback, None, 0.0, 0.0) + if r_axle: + self.boxes.hole(0, 0, r_axle) points = [] for i in range(teeth): m = [[tooth_width_scale, 0, 0], @@ -113,3 +121,6 @@ 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.boxes.ctx.restore() + self.boxes.move(total_width, total_width, move)