Docs: Added note that coordinates in script context might be None

Wasn't made clear before.
This commit is contained in:
Gina Häußge 2017-05-03 20:18:11 +02:00
parent 844494a9d5
commit f32d7c434d
2 changed files with 10 additions and 7 deletions

View file

@ -78,13 +78,15 @@ There are a few additional template variables available for the following specif
* ``pause_position``: Position reported by the printer via ``M114`` immediately before the print was paused. Consists
of ``x``, ``y``, ``z`` and ``e`` coordinates as received by the printer and tracked values for ``f`` and current tool
``t`` taken from commands sent through OctoPrint.
``t`` taken from commands sent through OctoPrint. All of these coordinates might be ``None`` if no position could be
retrieved from the printer or the values could not be tracked (in case of ``f`` and ``t``)!
* ``afterPrintCancelled``
* ``cancel_position``: Position reported by the printer via ``M114`` immediately before the print was cancelled.
Consists of ``x``, ``y``, ``z`` and ``e`` coordinates as received by the printer and tracked values for ``f`` and
current tool ``t`` taken from commands sent through OctoPrint.
current tool ``t`` taken from commands sent through OctoPrint. All of these coordinates might be ``None`` if no
position could be retrieved from the printer or the values could not be tracked (in case of ``f`` and ``t``)!
.. warning::

View file

@ -228,11 +228,11 @@ class PositionRecord(object):
def as_dict(self):
return dict(x=self.x,
y=self.y,
z=self.z,
e=self.e,
t=self.t,
f=self.f)
y=self.y,
z=self.z,
e=self.e,
t=self.t,
f=self.f)
class MachineCom(object):
STATE_NONE = 0
@ -1181,6 +1181,7 @@ class MachineCom(object):
# there's no way to query it from the firmware and
# no way to track it ourselves when not streaming
# the file - this all sucks sooo much
self.last_position.valid = True
self.last_position.x = float(match.group("x"))
self.last_position.y = float(match.group("y"))
self.last_position.z = float(match.group("z"))