Make material finding more robust

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

Hopefully contributes to issue #2053.
This commit is contained in:
Ghostkeeper 2017-07-06 09:41:28 +02:00
parent 271d4a30f0
commit bb68f488db
No known key found for this signature in database
GPG key ID: C5F96EE2BC0F7E75

View file

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