Skip to content

Instantly share code, notes, and snippets.

@urish
Created July 24, 2019 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urish/ecc45bde6c20edf2b56d69a720289db9 to your computer and use it in GitHub Desktop.
Save urish/ecc45bde6c20edf2b56d69a720289db9 to your computer and use it in GitHub Desktop.
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