diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index 62bf396878..e0ec6c4d14 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Ultimaker B.V. +# Copyright (c) 2020 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant # For communicating data and events to Qt. @@ -275,6 +275,25 @@ class ExtruderManager(QObject): Logger.log("e", "Unable to find one or more of the extruders in %s", used_extruder_stack_ids) return [] + ## Get the extruder that the print will start with. + # + # This should mirror the implementation in CuraEngine of + # ``FffGcodeWriter::getStartExtruder()``. + def getInitialExtruderNr(self) -> int: + application = cura.CuraApplication.CuraApplication.getInstance() + global_stack = application.getGlobalContainerStack() + + # Starts with the adhesion extruder. + if global_stack.getProperty("adhesion_type", "value") != "none": + return global_stack.getProperty("adhesion_extruder_nr", "value") + + # No adhesion? Well maybe there is still support brim. + if (global_stack.getProperty("support_enable", "value") or global_stack.getProperty("support_tree_enable", "value")) and global_stack.getProperty("support_brim_enable", "value"): + return global_stack.getProperty("support_infill_extruder_nr", "value") + + # REALLY no adhesion? Use the first used extruder. + return self.getUsedExtruderStacks()[0].getProperty("extruder_nr", "value") + ## Removes the container stack and user profile for the extruders for a specific machine. # # \param machine_id The machine to remove the extruders for. diff --git a/plugins/CuraEngineBackend/StartSliceJob.py b/plugins/CuraEngineBackend/StartSliceJob.py index 26b78dbfbd..c6841c6ea9 100644 --- a/plugins/CuraEngineBackend/StartSliceJob.py +++ b/plugins/CuraEngineBackend/StartSliceJob.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Ultimaker B.V. +# Copyright (c) 2020 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import numpy @@ -343,10 +343,7 @@ class StartSliceJob(Job): result["time"] = time.strftime("%H:%M:%S") #Some extra settings. result["date"] = time.strftime("%d-%m-%Y") result["day"] = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][int(time.strftime("%w"))] - - initial_extruder_stack = CuraApplication.getInstance().getExtruderManager().getUsedExtruderStacks()[0] - initial_extruder_nr = initial_extruder_stack.getProperty("extruder_nr", "value") - result["initial_extruder_nr"] = initial_extruder_nr + result["initial_extruder_nr"] = CuraApplication.getInstance().getExtruderManager().getInitialExtruderNr() return result