diff --git a/src/octoprint/cli/analysis.py b/src/octoprint/cli/analysis.py index 34c90d78d..bb69de05c 100644 --- a/src/octoprint/cli/analysis.py +++ b/src/octoprint/cli/analysis.py @@ -71,3 +71,6 @@ def gcode_command(path, speedx, speedy, speedz, offset, maxt, throttle, throttle click.echo("DONE:{}s".format(time.time() - start_time)) click.echo("RESULTS:") click.echo(yaml.safe_dump(interpreter.get_result(), default_flow_style=False, indent=" ", allow_unicode=True)) + +if __name__ == "__main__": + gcode_command() diff --git a/src/octoprint/util/gcodeInterpreter.py b/src/octoprint/util/gcodeInterpreter.py index 061564ce0..b9faf9765 100644 --- a/src/octoprint/util/gcodeInterpreter.py +++ b/src/octoprint/util/gcodeInterpreter.py @@ -152,12 +152,12 @@ class MinMax3D(object): self.max = Vector3D(None, None, None) def record(self, coordinate): - for c in "xyz": - current_min = getattr(self.min, c) - current_max = getattr(self.max, c) - value = getattr(coordinate, c) - setattr(self.min, c, value if current_min is None or value < current_min else current_min) - setattr(self.max, c, value if current_max is None or value > current_max else current_max) + self.min.x = coordinate.x if not self.min.x else min(self.min.x, coordinate.x) + self.min.y = coordinate.y if not self.min.y else min(self.min.y, coordinate.y) + self.min.z = coordinate.z if not self.min.z else min(self.min.z, coordinate.z) + self.max.x = coordinate.x if not self.max.x else max(self.max.x, coordinate.x) + self.max.y = coordinate.y if not self.max.y else max(self.max.y, coordinate.y) + self.max.z = coordinate.z if not self.max.z else max(self.max.z, coordinate.z) @property def size(self): @@ -498,7 +498,6 @@ def getCodeInt(line, code): def getCodeFloat(line, code): - import math n = line.find(code) + 1 if n < 1: return None @@ -511,4 +510,3 @@ def getCodeFloat(line, code): return val if not (math.isnan(val) or math.isinf(val)) else None except: return None -