Skip to content

Commit

Permalink
Fix getInitialExtruder code
Browse files Browse the repository at this point in the history
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
  • Loading branch information
casperlamboo committed Jan 23, 2024
1 parent a41d8aa commit 8af3de2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cura/Settings/ExtruderManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,13 @@ def getInitialExtruderNr(self) -> int:
# 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")

Expand Down

2 comments on commit 8af3de2

@casperlamboo
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit fixes the situation where the first extruder is not used at all, previously the initial extruder would always default to 0 but with the fix it will correctly determine the initial extruder to be 1. I don't think the fix is perfect though, it is hard to determine in the front end what the initial extruder is. I think the logic will fail in the situation where the first extruder is used, but not on the first layer. In this case we will start printing with extruder 1 but since the 0-th extruder is in in the used_extruders list extruder 1 is determined to be the first extruder.

@wawanbreton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the fix is perfect though, it is hard to determine in the front end what the initial extruder is

Completely agree. Whatever the front-end does, it is impossible to be 100% sure of what the engine will actually do. So there are probably other situations where the initial extruder will not be correct. However, this commit really makes sense and fixes a case where we can actually be (quite) sure.

Please sign in to comment.