Skip to content

Instantly share code, notes, and snippets.

@justinledwards
Created August 12, 2014 20:20
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 justinledwards/ad7154f6e39066c4726f to your computer and use it in GitHub Desktop.
Save justinledwards/ad7154f6e39066c4726f to your computer and use it in GitHub Desktop.
Retract post process
#!/usr/bin/env ruby
#filepath = "/home/user/whatever.gcode"
#chmod +x this file
# ./thisfile.rb "/file/path.here" > "/new/file.path"
filepath = ARGV[0].to_s
puts filepath
IO.write(filepath, File.open(filepath) {|f| f.read.gsub(/G1 E-1.*\nG0/, "G1 E-1")})
previous_line = ""
File.foreach(filepath) do |line|
if line.match(/^G1 E-/)
puts line.gsub(/F\d\d\d\d/, "F3500")
else
puts line
end
previous_line = line
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment