-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgcode_test.py
More file actions
31 lines (27 loc) · 775 Bytes
/
gcode_test.py
File metadata and controls
31 lines (27 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import tkinter as tk
from tkinter import filedialog
import matplotlib.pyplot as plt
# Wyświetlenie okna dialogowego i wybór pliku GCode
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename()
# Wczytanie pliku GCode
with open(file_path, 'r') as f:
lines = f.readlines()
# Przetworzenie linii GCode i wyodrębnienie informacji o współrzędnych
x = []
y = []
for line in lines:
if line.startswith('G1'):
tokens = line.split(' ')
for token in tokens:
if token.startswith('X'):
x.append(float(token[1:]))
elif token.startswith('Y'):
y.append(float(token[1:]))
# Wygenerowanie wykresu
fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_aspect('equal')
ax.invert_yaxis()
plt.show()