# A simple script to convert the output of Skeinforge # into a form useable by EMC2. # # This code: # 1) Removes all M codes # 2) Replaces 'E' with 'A', as the A axis is used to control the extruder motor # 3) Adds "M30" as the final line so that AXIS does not complain about the file # 4) Allows the A values to be scaled by the #1 variable # 5) Sets the A position to 0 before it is otherwise used. # 6) Sets EMC2 into G64 mode with a precision specification of 0.1mm # # The code is hereby released into the public domain. # # To run the code: # awk -f fixup.awk inputfile.gcode > outputfile.ngc # BEGIN{ print "#1=1"; } NR==3{ print "G92 A0"; print "G64 P0.1"; } /^M/{ next; } /E/{ i = index($0,"E"); b = substr($0,0,i-1); i = i + 1; n = ""; c = substr($0,i,1); while( ( c >= "0" && c <= "9" ) || c == "." || c == "-" ) { n = n c; i = i + 1; c = substr($0,i,1); } nn = n + 0; print b "A[" nn "*#1]" substr($0,i+1); next; } { print $0 } END{ print "M30"; }