Browse Source

Make material finding more robust

The .findContainer technique is obsolete since we now just have a field for this.

Hopefully contributes to issue #2053.
Ghostkeeper 7 years ago
parent
commit
bb68f488db
1 changed files with 3 additions and 6 deletions
  1. 3 6
      plugins/CuraEngineBackend/ProcessSlicedLayersJob.py

+ 3 - 6
plugins/CuraEngineBackend/ProcessSlicedLayersJob.py

@@ -173,19 +173,16 @@ class ProcessSlicedLayersJob(Job):
         if extruders:
             material_color_map = numpy.zeros((len(extruders), 4), dtype=numpy.float32)
             for extruder in extruders:
-                material = extruder.findContainer({"type": "material"})
                 position = int(extruder.getMetaDataEntry("position", default="0"))  # Get the position
-                color_code = material.getMetaDataEntry("color_code", default="#e0e000")
+                color_code = extruder.material.getMetaDataEntry("color_code", default="#e0e000")
                 color = colorCodeToRGBA(color_code)
                 material_color_map[position, :] = color
         else:
             # Single extruder via global stack.
             material_color_map = numpy.zeros((1, 4), dtype=numpy.float32)
-            material = global_container_stack.findContainer({"type": "material"})
             color_code = "#e0e000"
-            if material:
-                if material.getMetaDataEntry("color_code") is not None:
-                    color_code = material.getMetaDataEntry("color_code")
+            if global_container_stack.material.getMetaDataEntry("color_code") is not None:
+                color_code = global_container_stack.material.getMetaDataEntry("color_code")
             color = colorCodeToRGBA(color_code)
             material_color_map[0, :] = color