Created
May 17, 2016 14:45
-
-
Save AdoHaha/a2d52f7974f47ab0a26eddebd1103e56 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
import sys | |
filename = sys.argv[-1] | |
gcode = open(filename) | |
data = gcode.read() | |
def replace(match): | |
match = match.group(2) | |
#print match | |
serious_zaok=str(round(float("0."+match),5)) | |
print match | |
print "zaok",serious_zaok[2:7] | |
return "."+serious_zaok[2:7] | |
return "." + match[0:4] | |
pattern = re.compile(r"([.])([0-9]+)") | |
output = re.sub(pattern, replace, data) | |
output = re.sub(r'T0 M6',r'(TO M6) (gives error on grbl)',output) | |
new_filename = filename[:-3] + '-truncated.nc' | |
file = open(new_filename, "w") | |
file.write("(Modified by metric-gcode-truncator. Intended for use in absolute mode. Incremental mode may cause errors.)") | |
file.write(output) | |
file.close() | |
gcode.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment