From 8648e9fcd1187d9b7d99730127acba746ac4dae0 Mon Sep 17 00:00:00 2001 From: spirkelmann Date: Thu, 12 Sep 2019 08:23:18 +0200 Subject: [PATCH] added code for cutting center hole and lines for assembling from multiple parts --- prototype/circles.py | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/prototype/circles.py b/prototype/circles.py index 63506d0..8159d15 100644 --- a/prototype/circles.py +++ b/prototype/circles.py @@ -193,7 +193,8 @@ class PlateLayout: # compute coordinates and various measurements for fixed radii of plate and tubes self.target_plate_radius = 160.0 - self.target_radius_1 = 50.0 + self.target_center_hole_radius = 7.5 + self.target_radius_1 = 50.2 self.target_radius_2 = 20.0 teeth = 200 @@ -397,6 +398,32 @@ class PlateLayout: f_lines = f.readlines() f.close() + + circle_found = False + for k in range(len(f_lines)): + current_line = f_lines[k] + + if 'transform' in current_line: + # rotate gear such that teeth match the cut lines + index = current_line.find('"\n') + f_lines[k] = current_line[0:index] + " rotate(0.9)" + current_line[-2:] + + if 'd="m ' in current_line: + # remove center whole drawn by gear-dev + gear_data = current_line + index = gear_data.find('z') # end of path containing gear outline coordinates + + f_lines[k] = gear_data[0:index+1] + gear_data[-2:] + + + if ' command f_lines.remove(f_lines[-1]) # output plate as svg @@ -444,7 +471,6 @@ class PlateLayout: f_lines = f_lines + text pass - # output cuts for big circles for k, c in self.tube_1_cuts.items(): text = svg_rectangle(k, 'cut', c['center'], c['length'], c['width'], c['angle_deg']) @@ -462,8 +488,8 @@ class PlateLayout: a = a/360.0 * 2.0 * np.pi r1 = np.linalg.norm(np.array(self.tube_1_coords[k])) - self.target_radius_1 vunit = np.array([np.cos(a), np.sin(a)]) - p1 = np.zeros(2) - p2 = p1 + vunit * r1 + p1 = vunit * self.target_center_hole_radius + p2 = vunit * r1 text = svg_line(p1, p2, 0.1) f_lines = f_lines + text @@ -476,7 +502,6 @@ class PlateLayout: pass - f_lines.append('\n') # write new svg image