Make getValue return an int if it's an integer number

This is a more generic solution to what's done in 7058ddbb66.

Contributes to issue CURA-5491.
This commit is contained in:
Ghostkeeper 2018-07-09 09:01:52 +02:00
parent 183cd0182d
commit 6977b8de6e
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A
2 changed files with 9 additions and 6 deletions

View file

@ -104,9 +104,12 @@ class Script:
m = re.search('^-?[0-9]+\.?[0-9]*', sub_part)
if m is None:
return default
try:
return int(m.group(0))
except ValueError: #Not an integer.
try:
return float(m.group(0))
except:
except ValueError: #Not a number at all.
return default
## Convenience function to produce a line of g-code.

View file

@ -162,12 +162,12 @@ class PauseAtHeight(Script):
#Track the latest printing temperature in order to resume at the correct temperature.
if line.startswith("T"):
current_t = int(self.getValue(line, "T"))
current_t = self.getValue(line, "T")
m = self.getValue(line, "M")
if m is not None and (int(m) == 104 or int(m) == 109) and self.getValue(line, "S") is not None:
if m is not None and (m == 104 or m == 109) and self.getValue(line, "S") is not None:
extruder = current_t
if self.getValue(line, "T") is not None:
extruder = int(self.getValue(line, "T"))
extruder = self.getValue(line, "T")
target_temperature[extruder] = self.getValue(line, "S")
if not layers_started: