Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2020-02-05 14:52:54 +0300
committerGhostkeeper <rubend@tutanota.com>2020-02-05 14:52:54 +0300
commit341e149d0ebce31c1bd6c266e530bebf0f20a120 (patch)
treee9371f939b2b90d86daa0b783a2cb31c28285ffc /plugins/GCodeReader
parent53d69f3f26d7bbf465849d1df4a6d51b6cbbd040 (diff)
Ignore g-code lines with syntax errors
Discovered while working on CURA-7145.
Diffstat (limited to 'plugins/GCodeReader')
-rw-r--r--plugins/GCodeReader/FlavorParser.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/plugins/GCodeReader/FlavorParser.py b/plugins/GCodeReader/FlavorParser.py
index d05338ae4d..7bb9ad0e4a 100644
--- a/plugins/GCodeReader/FlavorParser.py
+++ b/plugins/GCodeReader/FlavorParser.py
@@ -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.
import math
@@ -258,16 +258,19 @@ class FlavorParser:
continue
if item.startswith(";"):
continue
- if item[0] == "X":
- x = float(item[1:])
- if item[0] == "Y":
- y = float(item[1:])
- if item[0] == "Z":
- z = float(item[1:])
- if item[0] == "F":
- f = float(item[1:]) / 60
- if item[0] == "E":
- e = float(item[1:])
+ try:
+ if item[0] == "X":
+ x = float(item[1:])
+ if item[0] == "Y":
+ y = float(item[1:])
+ if item[0] == "Z":
+ z = float(item[1:])
+ if item[0] == "F":
+ f = float(item[1:]) / 60
+ 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)
return func(position, params, path)
return position