mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-12 06:09:02 +08:00
Check len(materialLengths) before using
CURA-3604
This commit is contained in:
parent
ef666aac88
commit
c785e84b86
@ -624,7 +624,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
|||||||
if print_information.materialLengths:
|
if print_information.materialLengths:
|
||||||
# Check if print cores / materials are loaded at all. Any failure in these results in an Error.
|
# Check if print cores / materials are loaded at all. Any failure in these results in an Error.
|
||||||
for index in range(0, self._num_extruders):
|
for index in range(0, self._num_extruders):
|
||||||
if print_information.materialLengths[index] != 0:
|
if index < len(print_information.materialLengths) and print_information.materialLengths[index] != 0:
|
||||||
if self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"] == "":
|
if self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"] == "":
|
||||||
Logger.log("e", "No cartridge loaded in slot %s, unable to start print", index + 1)
|
Logger.log("e", "No cartridge loaded in slot %s, unable to start print", index + 1)
|
||||||
self._error_message = Message(
|
self._error_message = Message(
|
||||||
@ -642,13 +642,13 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
|||||||
for index in range(0, self._num_extruders):
|
for index in range(0, self._num_extruders):
|
||||||
# Check if there is enough material. Any failure in these results in a warning.
|
# Check if there is enough material. Any failure in these results in a warning.
|
||||||
material_length = self._json_printer_state["heads"][0]["extruders"][index]["active_material"]["length_remaining"]
|
material_length = self._json_printer_state["heads"][0]["extruders"][index]["active_material"]["length_remaining"]
|
||||||
if material_length != -1 and print_information.materialLengths[index] > material_length:
|
if material_length != -1 and index < len(print_information.materialLengths) and print_information.materialLengths[index] > material_length:
|
||||||
Logger.log("w", "Printer reports that there is not enough material left for extruder %s. We need %s and the printer has %s", index + 1, print_information.materialLengths[index], material_length)
|
Logger.log("w", "Printer reports that there is not enough material left for extruder %s. We need %s and the printer has %s", index + 1, print_information.materialLengths[index], material_length)
|
||||||
warnings.append(i18n_catalog.i18nc("@label", "Not enough material for spool {0}.").format(index+1))
|
warnings.append(i18n_catalog.i18nc("@label", "Not enough material for spool {0}.").format(index+1))
|
||||||
|
|
||||||
# Check if the right cartridges are loaded. Any failure in these results in a warning.
|
# Check if the right cartridges are loaded. Any failure in these results in a warning.
|
||||||
extruder_manager = cura.Settings.ExtruderManager.ExtruderManager.getInstance()
|
extruder_manager = cura.Settings.ExtruderManager.ExtruderManager.getInstance()
|
||||||
if print_information.materialLengths[index] != 0:
|
if index < len(print_information.materialLengths) and print_information.materialLengths[index] != 0:
|
||||||
variant = extruder_manager.getExtruderStack(index).findContainer({"type": "variant"})
|
variant = extruder_manager.getExtruderStack(index).findContainer({"type": "variant"})
|
||||||
core_name = self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"]
|
core_name = self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"]
|
||||||
if variant:
|
if variant:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user