Browse Source

Fix `getInitialExtruder` code

For the `skirt_brim_extruder_nr` setting it is possible for the setting to be -1; this means that we have no preference for extruder. This allowed us to implement the "multi-material brim". When we were requesting the initial extruder, and this value was set to -1 we were default to the 0-th extruder. However, this was incorrect in the situation where the first extruder is not used.

Fixes #17501
c.lamboo 1 year ago
parent
commit
8af3de2178
1 changed files with 7 additions and 1 deletions
  1. 7 1
      cura/Settings/ExtruderManager.py

+ 7 - 1
cura/Settings/ExtruderManager.py

@@ -316,7 +316,13 @@ class ExtruderManager(QObject):
         # Starts with the adhesion extruder.
         adhesion_type = global_stack.getProperty("adhesion_type", "value")
         if adhesion_type in {"skirt", "brim"}:
-            return max(0, int(global_stack.getProperty("skirt_brim_extruder_nr", "value")))  # optional skirt/brim extruder defaults to zero
+            skirt_brim_extruder_nr = global_stack.getProperty("skirt_brim_extruder_nr", "value")
+            # if the skirt_brim_extruder_nr is -1, then we use the first used extruder
+            if skirt_brim_extruder_nr == -1:
+                used_extruders = self.getUsedExtruderStacks()
+                return used_extruders[0].position
+            else:
+                return skirt_brim_extruder_nr
         if adhesion_type == "raft":
             return global_stack.getProperty("raft_base_extruder_nr", "value")