Skip to content

Instantly share code, notes, and snippets.

@jediminer543
Created July 29, 2019 19:09
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 jediminer543/1eb17f3113503c30e373bb59260a4dcf to your computer and use it in GitHub Desktop.
Save jediminer543/1eb17f3113503c30e373bb59260a4dcf to your computer and use it in GitHub Desktop.
python turtle gcode viewer
import turtle
turtle.penup()
gcode = open("gcode.test", "r")
for line in gcode:
command = { i[0] : int(i[1:]) for i in line.split() }
if "M" in command:
if command["M"] == 5:
turtle.penup()
elif command["M"] == 3:
turtle.pendown()
turtle.pencolor(command["S"], command["S"], command["S"])
if "G" in command:
if command["G"] == 0 or command["G"] == 1:
turtle.moveto(command.get("X", turtle.pos()[0]), command.get("X", turtle.pos()[1]))
print("Done");
input();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment