From 3fcfbb4e488abdbd4fb7274ea48458ec3199dba7 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 21 Jun 2016 22:10:50 +0200 Subject: [PATCH] Fix extruder color when no extruder_nr has been added to an object CURA-345 --- plugins/SolidView/SolidView.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 6f63e332c9..f69ac61a02 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -61,21 +61,20 @@ class SolidView(View): extruder_index = 0 extruder_id = node.callDecoration("getActiveExtruder") if extruder_id: - extruder_index = self._extruders_model.find("id", extruder_id) - if extruder_index: - extruder_color = self._extruders_model.getItem(extruder_index)["color"] + extruder_index = max(0, self._extruders_model.find("id", extruder_id)) - try: - # Colors are passed as rgb hex strings (eg "#ffffff"), and the shader needs - # an rgba list of floats (eg [1.0, 1.0, 1.0, 1.0]) - uniforms["diffuse_color"] = [ - int(extruder_color[1:3], 16) / 255, - int(extruder_color[3:5], 16) / 255, - int(extruder_color[5:7], 16) / 255, - 1.0 - ] - except: - pass + extruder_color = self._extruders_model.getItem(extruder_index)["color"] + try: + # Colors are passed as rgb hex strings (eg "#ffffff"), and the shader needs + # an rgba list of floats (eg [1.0, 1.0, 1.0, 1.0]) + uniforms["diffuse_color"] = [ + int(extruder_color[1:3], 16) / 255, + int(extruder_color[3:5], 16) / 255, + int(extruder_color[5:7], 16) / 255, + 1.0 + ] + except: + pass if hasattr(node, "_outside_buildarea"): if node._outside_buildarea: