mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 19:28:07 -06:00
T466: Improved parsing
This commit is contained in:
parent
8aa3b1b38c
commit
eb649511a7
1 changed files with 33 additions and 15 deletions
|
@ -29,9 +29,9 @@ class GCODEReader(MeshReader):
|
||||||
if n < 1:
|
if n < 1:
|
||||||
return None
|
return None
|
||||||
m = line.find(' ', n)
|
m = line.find(' ', n)
|
||||||
m2 = line.find(';', n)
|
# m2 = line.find(';', n)
|
||||||
if m < 0:
|
# if m < 0:
|
||||||
m = m2
|
# m = m2
|
||||||
try:
|
try:
|
||||||
if m < 0:
|
if m < 0:
|
||||||
return int(line[n:])
|
return int(line[n:])
|
||||||
|
@ -44,9 +44,9 @@ class GCODEReader(MeshReader):
|
||||||
if n < 1:
|
if n < 1:
|
||||||
return None
|
return None
|
||||||
m = line.find(' ', n)
|
m = line.find(' ', n)
|
||||||
m2 = line.find(';', n)
|
# m2 = line.find(';', n)
|
||||||
if m < 0:
|
# if m < 0:
|
||||||
m = m2
|
# m = m2
|
||||||
try:
|
try:
|
||||||
if m < 0:
|
if m < 0:
|
||||||
return float(line[n:])
|
return float(line[n:])
|
||||||
|
@ -95,6 +95,7 @@ class GCODEReader(MeshReader):
|
||||||
current_x = 0
|
current_x = 0
|
||||||
current_y = 0
|
current_y = 0
|
||||||
current_z = 0
|
current_z = 0
|
||||||
|
current_e = 0
|
||||||
|
|
||||||
def CreatePolygon():
|
def CreatePolygon():
|
||||||
count = len(current_path)
|
count = len(current_path)
|
||||||
|
@ -126,32 +127,49 @@ class GCODEReader(MeshReader):
|
||||||
if line[0] == ";":
|
if line[0] == ";":
|
||||||
continue
|
continue
|
||||||
G = self.getInt(line, "G")
|
G = self.getInt(line, "G")
|
||||||
if G:
|
if G is not None:
|
||||||
if G == 0 or G == 1:
|
if G == 0 or G == 1:
|
||||||
x = self.getFloat(line, "X")
|
x = self.getFloat(line, "X")
|
||||||
y = self.getFloat(line, "Y")
|
y = self.getFloat(line, "Y")
|
||||||
z = self.getFloat(line, "Z")
|
z = self.getFloat(line, "Z")
|
||||||
e = self.getFloat(line, "E")
|
e = self.getFloat(line, "E")
|
||||||
if x:
|
if x is not None:
|
||||||
current_x = x
|
current_x = x
|
||||||
if y:
|
if y is not None:
|
||||||
current_y = y
|
current_y = y
|
||||||
if z:
|
if z is not None:
|
||||||
current_z = z
|
current_z = z
|
||||||
if e and e > 0:
|
if e is not None:
|
||||||
current_path.append([current_x, current_z, -current_y])
|
if e >= current_e:
|
||||||
|
current_path.append([current_x, current_z, -current_y])
|
||||||
|
else:
|
||||||
|
if len(current_path) > 1:
|
||||||
|
CreatePolygon()
|
||||||
|
else:
|
||||||
|
current_path.clear()
|
||||||
|
current_e = e
|
||||||
else:
|
else:
|
||||||
if len(current_path) > 1:
|
if len(current_path) > 1:
|
||||||
CreatePolygon()
|
CreatePolygon()
|
||||||
|
else:
|
||||||
|
current_path.clear()
|
||||||
|
elif G == 28:
|
||||||
|
x = self.getFloat(line, "X")
|
||||||
|
y = self.getFloat(line, "Y")
|
||||||
|
if x is not None:
|
||||||
|
current_x += x
|
||||||
|
if y is not None:
|
||||||
|
current_y += y
|
||||||
|
current_z = 0
|
||||||
elif G == 92:
|
elif G == 92:
|
||||||
x = self.getFloat(line, "X")
|
x = self.getFloat(line, "X")
|
||||||
y = self.getFloat(line, "Y")
|
y = self.getFloat(line, "Y")
|
||||||
z = self.getFloat(line, "Z")
|
z = self.getFloat(line, "Z")
|
||||||
if x:
|
if x is not None:
|
||||||
current_x += x
|
current_x += x
|
||||||
if y:
|
if y is not None:
|
||||||
current_y += y
|
current_y += y
|
||||||
if z:
|
if z is not None:
|
||||||
current_z += z
|
current_z += z
|
||||||
|
|
||||||
if len(current_path) > 1:
|
if len(current_path) > 1:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue