Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix GCode generated by Inkscape
import re
f = open('dna_pattern.gcode', 'r')
output = open('dna_output.gcode', 'w')
output.write('; Home\nG28\n')
for line in f:
line = line.strip()
if line[0:1] == '(':
output.write('; ' + re.sub(r'^\s*\(|\)\s*$', '', line) + '\n')
if line[0:2] == 'G0':
cmd = re.sub(r'\([^\)]*\)', '', line[3:])
output.write(line[0:2] + ' F1000' + cmd + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment