Browse Source

Fix typing

Lipu Fei 5 years ago
parent
commit
6e625b2cf8
1 changed files with 4 additions and 3 deletions
  1. 4 3
      cura/Settings/MachineManager.py

+ 4 - 3
cura/Settings/MachineManager.py

@@ -1305,9 +1305,10 @@ class MachineManager(QObject):
                 self._setMaterial(position_item, new_material)
                 self._setMaterial(position_item, new_material)
             else:
             else:
                 # The current material is not available, find the preferred one.
                 # The current material is not available, find the preferred one.
-                approximate_material_diameter = int(self._global_container_stack.extruderList[int(position)].getApproximateMaterialDiameter())
-                material_node = nozzle_node.preferredMaterial(approximate_material_diameter)
-                self._setMaterial(position_item, material_node)
+                if position is not None:
+                    approximate_material_diameter = int(self._global_container_stack.extruderList[int(position)].getApproximateMaterialDiameter())
+                    material_node = nozzle_node.preferredMaterial(approximate_material_diameter)
+                    self._setMaterial(position_item, material_node)
 
 
     ##  Given a printer definition name, select the right machine instance. In case it doesn't exist, create a new
     ##  Given a printer definition name, select the right machine instance. In case it doesn't exist, create a new
     #   instance with the same network key.
     #   instance with the same network key.