From 95e4ad82b4cefbe757cefa195625b524cc39c323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 13 Jan 2017 11:25:08 +0100 Subject: [PATCH] Cura: Fix off-by-one error for placeholder replacement Affected print_temperature and filament_diameter placeholders. E.g. `print_temperature2` was wrongly attempting to fetch `print_temperatures[2]` instead of `print_temperatures[1]` (0-based-indexing!) Partially fixes #1708 --- src/octoprint/plugins/cura/profile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/octoprint/plugins/cura/profile.py b/src/octoprint/plugins/cura/profile.py index e8783d12..5f8538bd 100644 --- a/src/octoprint/plugins/cura/profile.py +++ b/src/octoprint/plugins/cura/profile.py @@ -602,8 +602,8 @@ class Profile(object): diameters = self._get("filament_diameter") if not match.group(1): return diameters[0] - index = int(match.group(1)) - if index >= len(diameters): + index = int(match.group(1)) - 1 + if index >= len(diameters) or index < 0: return 0.0 return diameters[index] @@ -615,8 +615,8 @@ class Profile(object): temperatures = self._get("print_temperature") if not match.group(1): return temperatures[0] - index = int(match.group(1)) - if index >= len(temperatures): + index = int(match.group(1)) - 1 + if index >= len(temperatures) or index < 0: return 0.0 return temperatures[index]