Fix layer change travel if no sparse layers is enabled

This commit is contained in:
Martin Šach 2024-09-17 11:26:52 +02:00
parent 2cac8c2c37
commit 33bafd28e3
2 changed files with 16 additions and 2 deletions

View File

@ -540,7 +540,8 @@ std::vector<ExtruderExtrusions> get_extrusions(
if (layer_tools.has_wipe_tower && wipe_tower != nullptr) {
const bool finish_wipe_tower{extruder_id == layer_tools.extruders.back()};
if (finish_wipe_tower || is_toolchange_required(is_first_layer, layer_tools.extruders.back(), extruder_id, current_extruder_id)) {
if (const auto tool_change{wipe_tower->get_toolchange(toolchange_number)}) {
const bool ignore_sparse{print.config().wipe_tower_no_sparse_layers.value};
if (const auto tool_change{wipe_tower->get_toolchange(toolchange_number, ignore_sparse)}) {
toolchange_number++;
previous_position = Point::new_scale(wipe_tower->transform_wt_pt(tool_change->end_pos));
current_extruder_id = tool_change->new_tool;

View File

@ -42,10 +42,23 @@ public:
std::string tool_change(GCodeGenerator &gcodegen, int extruder_id, bool finish_layer);
std::string finalize(GCodeGenerator &gcodegen);
std::vector<float> used_filament_length() const;
std::optional<WipeTower::ToolChangeResult> get_toolchange(std::size_t index) const {
std::optional<WipeTower::ToolChangeResult> get_toolchange(std::size_t index, bool ignore_sparse) const {
if (m_layer_idx >= m_tool_changes.size()) {
return std::nullopt;
}
if(
ignore_sparse
&& m_tool_changes.at(m_layer_idx).size() == 1
&& (
m_tool_changes.at(m_layer_idx).front().initial_tool
== m_tool_changes.at(m_layer_idx).front().new_tool
)
&& m_layer_idx != 0
) {
// Ignore sparse
return std::nullopt;
}
return m_tool_changes.at(m_layer_idx).at(index);
}