|
@@ -38,11 +38,11 @@ lines_of_g1 = 0
|
38
|
38
|
gcode = []
|
39
|
39
|
|
40
|
40
|
|
41
|
|
-def found_g1(line):
|
|
41
|
+def has_g1(line):
|
42
|
42
|
return line[:2].upper() == "G1"
|
43
|
43
|
|
44
|
44
|
|
45
|
|
-def find(line, axis):
|
|
45
|
+def find_axis(line, axis):
|
46
|
46
|
found = False
|
47
|
47
|
number = ""
|
48
|
48
|
for char in line:
|
|
@@ -66,8 +66,8 @@ def find(line, axis):
|
66
|
66
|
def set_mima(line):
|
67
|
67
|
global min_x, max_x, min_y, max_y, last_z
|
68
|
68
|
|
69
|
|
- current_x = find(line, 'x')
|
70
|
|
- current_y = find(line, 'y')
|
|
69
|
+ current_x = find_axis(line, 'x')
|
|
70
|
+ current_y = find_axis(line, 'y')
|
71
|
71
|
|
72
|
72
|
if current_x is not None:
|
73
|
73
|
min_x = min(current_x, min_x)
|
|
@@ -81,7 +81,7 @@ def set_mima(line):
|
81
|
81
|
|
82
|
82
|
def find_z(gcode, start_at_line=0):
|
83
|
83
|
for i in range(start_at_line, len(gcode)):
|
84
|
|
- my_z = find(gcode[i], 'Z')
|
|
84
|
+ my_z = find_axis(gcode[i], 'Z')
|
85
|
85
|
if my_z is not None:
|
86
|
86
|
return my_z, i
|
87
|
87
|
|
|
@@ -122,13 +122,13 @@ def get_lines(gcode, minimum):
|
122
|
122
|
return z_at_line[i - 1], z_at_line[i]
|
123
|
123
|
|
124
|
124
|
|
125
|
|
-with open(my_file, 'r') as file:
|
|
125
|
+with open(folder+my_file, 'r') as file:
|
126
|
126
|
lines = 0
|
127
|
127
|
for line in file:
|
128
|
128
|
lines += 1
|
129
|
129
|
if lines > 1000:
|
130
|
130
|
break
|
131
|
|
- if found_g1(line):
|
|
131
|
+ if has_g1(line):
|
132
|
132
|
gcode.append(line)
|
133
|
133
|
file.close()
|
134
|
134
|
|