added code for cutting center hole and lines for assembling from multiple parts

master
Simon Pirkelmann 2019-09-12 08:23:18 +02:00
parent 850fe69847
commit 8648e9fcd1
1 changed files with 30 additions and 5 deletions

View File

@ -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 '<circle' in current_line:
circle_found = True
if circle_found and 'r=' in current_line:
# adjust center hole radius
f_lines[k] = ' r="{}mm"\n'.format(self.target_center_hole_radius)
# delete last line with </svg> 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('</svg>\n')
# write new svg image