diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.py b/plugins/UltimakerMachineActions/BedLevelMachineAction.py index b6ecdeec34..6a8a337d8c 100644 --- a/plugins/UltimakerMachineActions/BedLevelMachineAction.py +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.py @@ -32,14 +32,16 @@ class BedLevelMachineAction(MachineAction): @pyqtSlot() def startBedLeveling(self): self._bed_level_position = 0 + printer_output_devices = self._getPrinterOutputDevices() if not printer_output_devices: Logger.log("e", "Can't start bed levelling. The printer connection seems to have been lost.") return + printer = printer_output_devices[0].activePrinter - printer_output_devices[0].homeBed() - printer_output_devices[0].moveHead(0, 0, 3) - printer_output_devices[0].homeHead() + printer.homeBed() + printer.moveHead(0, 0, 3) + printer.homeHead() def _getPrinterOutputDevices(self) -> List[PrinterOutputDevice]: return [printer_output_device for printer_output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices() if isinstance(printer_output_device, PrinterOutputDevice)] @@ -50,26 +52,25 @@ class BedLevelMachineAction(MachineAction): if not output_devices: #No output devices. Can't move. Logger.log("e", "Can't move to the next position. The printer connection seems to have been lost.") return - - output_device = output_devices[0] + printer = output_devices[0].activePrinter if self._bed_level_position == 0: - output_device.moveHead(0, 0, 3) - output_device.homeHead() - output_device.moveHead(0, 0, 3) - output_device.moveHead(Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value") - 10, 0, 0) - output_device.moveHead(0, 0, -3) + printer.moveHead(0, 0, 3) + printer.homeHead() + printer.moveHead(0, 0, 3) + printer.moveHead(Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value") - 10, 0, 0) + printer.moveHead(0, 0, -3) self._bed_level_position += 1 elif self._bed_level_position == 1: - output_device.moveHead(0, 0, 3) - output_device.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value" ) / 2, Application.getInstance().getGlobalContainerStack().getProperty("machine_depth", "value") - 10, 0) - output_device.moveHead(0, 0, -3) + printer.moveHead(0, 0, 3) + printer.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value" ) / 2, Application.getInstance().getGlobalContainerStack().getProperty("machine_depth", "value") - 10, 0) + printer.moveHead(0, 0, -3) self._bed_level_position += 1 elif self._bed_level_position == 2: - output_device.moveHead(0, 0, 3) - output_device.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value") / 2 + 10, -(Application.getInstance().getGlobalContainerStack().getProperty("machine_depth", "value") + 10), 0) - output_device.moveHead(0, 0, -3) + printer.moveHead(0, 0, 3) + printer.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value") / 2 + 10, -(Application.getInstance().getGlobalContainerStack().getProperty("machine_depth", "value") + 10), 0) + printer.moveHead(0, 0, -3) self._bed_level_position += 1 elif self._bed_level_position >= 3: - output_device.sendCommand("M18") # Turn off all motors so the user can move the axes + output_devices[0].sendCommand("M18") # Turn off all motors so the user can move the axes self.setFinished() \ No newline at end of file