From 54c1980f782b1e38d24fcd09ff8e6bdb9bd585d6 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 4 Oct 2019 17:35:38 +0200 Subject: [PATCH] Fix preferring correct diameter over correct preference If the diameter doesn't match up, then the print fails. If the preference is not held up, then it chooses some random material and the user will understand what it chose. Done during Turbo Testing and Tooling because a test was failing. --- cura/Machines/VariantNode.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cura/Machines/VariantNode.py b/cura/Machines/VariantNode.py index d34580d465..fa0c61bd3d 100644 --- a/cura/Machines/VariantNode.py +++ b/cura/Machines/VariantNode.py @@ -82,6 +82,10 @@ class VariantNode(ContainerNode): for base_material, material_node in self.materials.items(): if self.machine.preferred_material in base_material and approximate_diameter == int(material_node.getMetaDataEntry("approximate_diameter")): return material_node + # First fallback: Choose any material with matching diameter. + for material_node in self.materials.values(): + if approximate_diameter == int(material_node.getMetaDataEntry("approximate_diameter")): + return material_node fallback = next(iter(self.materials.values())) # Should only happen with empty material node. Logger.log("w", "Could not find preferred material {preferred_material} with diameter {diameter} for variant {variant_id}, falling back to {fallback}.".format( preferred_material = self.machine.preferred_material,