Created
July 29, 2019 19:09
-
-
Save jediminer543/1eb17f3113503c30e373bb59260a4dcf to your computer and use it in GitHub Desktop.
python turtle gcode viewer
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 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