Browse Source

Don't find any variants if the machine says it doesn't have them

Even if there might be a matching variant...

Contributes to issue CURA-6600.
Ghostkeeper 5 years ago
parent
commit
0302ae4257

+ 4 - 0
cura/Machines/MachineNode.py

@@ -32,6 +32,7 @@ class MachineNode(ContainerNode):
         # ONLY DO THAT FOR METADATA THAT DOESN'T CHANGE DURING RUNTIME!
         # Otherwise you need to keep it up-to-date during runtime.
         self.has_materials = parseBool(my_metadata.get("has_materials", "true"))
+        self.has_variants = parseBool(my_metadata.get("has_variants", "false"))
         self.has_machine_materials = parseBool(my_metadata.get("has_machine_materials", "false"))
         self.has_machine_quality = parseBool(my_metadata.get("has_machine_quality", "false"))
         self.quality_definition = my_metadata.get("quality_definition", container_id)
@@ -91,6 +92,9 @@ class MachineNode(ContainerNode):
 
     ##  (Re)loads all variants under this printer.
     def _loadAll(self):
+        if not self.has_variants:
+            return
+
         # Find all the variants for this definition ID.
         container_registry = ContainerRegistry.getInstance()
         variants = container_registry.findInstanceContainersMetadata(type = "variant", definition = self.container_id, hardware_type = "nozzle")

+ 4 - 1
cura/Machines/Models/NozzleModel.py

@@ -1,4 +1,4 @@
-# Copyright (c) 2018 Ultimaker B.V.
+# Copyright (c) 2019 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 from PyQt5.QtCore import Qt
@@ -7,6 +7,7 @@ from UM.Application import Application
 from UM.Logger import Logger
 from UM.Qt.ListModel import ListModel
 from UM.Util import parseBool
+from cura.Machines.ContainerTree import ContainerTree
 
 from cura.Machines.VariantType import VariantType
 
@@ -37,6 +38,8 @@ class NozzleModel(ListModel):
         if global_stack is None:
             self.setItems([])
             return
+        machine_node = ContainerTree.getInstance().machines[global_stack.definition.getId()]
+
 
         has_variants = parseBool(global_stack.getMetaDataEntry("has_variants", False))
         if not has_variants:

+ 1 - 0
resources/definitions/fdmprinter.def.json

@@ -11,6 +11,7 @@
         "file_formats": "text/x-gcode;application/x-stl-ascii;application/x-stl-binary;application/x-wavefront-obj;application/x3g",
         "visible": false,
         "has_materials": true,
+        "has_variants": false,
         "preferred_material": "generic_pla",
         "preferred_quality_type": "normal",
         "machine_extruder_trains":