diff --git a/cura/ExtrudersModel.py b/cura/ExtrudersModel.py index 60bd60abab..37487f838c 100644 --- a/cura/ExtrudersModel.py +++ b/cura/ExtrudersModel.py @@ -51,13 +51,18 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): global_container_stack = UM.Application.getInstance().getGlobalContainerStack() if not global_container_stack: return #There is no machine to get the extruders of. - for index, extruder in enumerate(manager.getMachineExtruders(global_container_stack.getBottom())): + for extruder in manager.getMachineExtruders(global_container_stack.getBottom()): material = extruder.findContainer({ "type": "material" }) colour = material.getMetaDataEntry("color_code", default = "#FFFF00") if material else "#FFFF00" + position = extruder.getBottom().getMetaDataEntry("position", default = "0") #Position in the definition. + try: + position = int(position) + except ValueError: #Not a proper int. + position = -1 item = { #Construct an item with only the relevant information. "name": extruder.getName(), "colour": colour, - "index": index + "index": position } self.appendItem(item) self.sort(lambda item: item["index"]) \ No newline at end of file