Ignore g-code lines with syntax errors

Discovered while working on CURA-7145.
This commit is contained in:
Ghostkeeper 2020-02-05 12:52:54 +01:00
parent 53d69f3f26
commit 341e149d0e
No known key found for this signature in database
GPG key ID: 37E2020986774393

View file

@ -1,4 +1,4 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2020 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
import math import math
@ -258,16 +258,19 @@ class FlavorParser:
continue continue
if item.startswith(";"): if item.startswith(";"):
continue continue
if item[0] == "X": try:
x = float(item[1:]) if item[0] == "X":
if item[0] == "Y": x = float(item[1:])
y = float(item[1:]) if item[0] == "Y":
if item[0] == "Z": y = float(item[1:])
z = float(item[1:]) if item[0] == "Z":
if item[0] == "F": z = float(item[1:])
f = float(item[1:]) / 60 if item[0] == "F":
if item[0] == "E": f = float(item[1:]) / 60
e = float(item[1:]) if item[0] == "E":
e = float(item[1:])
except ValueError: # Improperly formatted g-code: Coordinates are not floats.
continue # Skip the command then.
params = PositionOptional(x, y, z, f, e) params = PositionOptional(x, y, z, f, e)
return func(position, params, path) return func(position, params, path)
return position return position