Fix extruder number attached to extruders

It reads that from position in the extruder definition file.

Contributes to issues CURA-1278 and CURA-340.
This commit is contained in:
Ghostkeeper 2016-06-09 11:35:23 +02:00
parent 5da3665832
commit 4bdd5713f1
No known key found for this signature in database
GPG Key ID: 701948C5954A7385

View File

@ -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"])