Skip to content

Commit

Permalink
Add fallback on last extruder of previous layer when used extruder li…
Browse files Browse the repository at this point in the history
…st is empty

CURA-11649
  • Loading branch information
casperlamboo committed Feb 23, 2024
1 parent e4d47de commit 24cfc94
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1173,13 +1173,29 @@ FffGcodeWriter::ProcessLayerResult FffGcodeWriter::processLayer(const SliceDataS
const std::vector<ExtruderUse>& extruder_order
= (layer_nr < 0) ? extruder_order_per_layer_negative_layers[extruder_order_per_layer_negative_layers.size() + layer_nr] : extruder_order_per_layer[layer_nr];

const coord_t first_outer_wall_line_width = scene.extruders[extruder_order.front().extruder_nr].settings_.get<coord_t>("wall_line_width_0");
size_t first_extruder;
if (extruder_order.size() > 0)
{
first_extruder = extruder_order.front().extruder_nr;
}
else
{
// find the last extruder used in the previous layer
size_t last_extruder_nr_layer = layer_nr - 1;
while (extruder_order_per_layer[last_extruder_nr_layer].size() == 0 && last_extruder_nr_layer >= 0)
{
last_extruder_nr_layer--;
}
first_extruder = extruder_order_per_layer[last_extruder_nr_layer].back().extruder_nr;
}

const coord_t first_outer_wall_line_width = scene.extruders[first_extruder].settings_.get<coord_t>("wall_line_width_0");
LayerPlan& gcode_layer = *new LayerPlan(
storage,
layer_nr,
z,
layer_thickness,
extruder_order.front().extruder_nr,
first_extruder,
fan_speed_layer_time_settings_per_extruder,
comb_offset_from_outlines,
first_outer_wall_line_width,
Expand Down

0 comments on commit 24cfc94

Please sign in to comment.