Created
July 24, 2019 10:28
-
-
Save urish/ecc45bde6c20edf2b56d69a720289db9 to your computer and use it in GitHub Desktop.
Fix GCode generated by Inkscape
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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