From 2e243b3e76b46ee56d45574e4a1dfc177508921a Mon Sep 17 00:00:00 2001 From: "xun.zhang" Date: Wed, 11 Sep 2024 12:12:57 +0800 Subject: [PATCH] FIX: missing flush for small purge length 1.Caused by round(), if purge volume is small, flush count may be 0 due to round() Github:#4738 Signed-off-by: xun.zhang Change-Id: I382ab3021761c2fcc84d3537a18bd619637985b8 --- src/libslic3r/GCode.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 44c0f2a5a..1cdc9eef6 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -508,6 +508,9 @@ static std::vector get_path_of_change_filament(const Print& print) config.set_key_value("flush_length", new ConfigOptionFloat(purge_length)); int flush_count = std::min(g_max_flush_count, (int)std::round(purge_volume / g_purge_volume_one_time)); + // handle cases for very small purge + if (flush_count == 0 && purge_volume > 0) + flush_count += 1; float flush_unit = purge_length / flush_count; int flush_idx = 0; for (; flush_idx < flush_count; flush_idx++) { @@ -5570,6 +5573,9 @@ std::string GCode::set_extruder(unsigned int extruder_id, double print_z, bool b dyn_config.set_key_value("flush_length", new ConfigOptionFloat(wipe_length)); int flush_count = std::min(g_max_flush_count, (int)std::round(wipe_volume / g_purge_volume_one_time)); + // handle cases for very small purge + if (flush_count == 0 && wipe_volume > 0) + flush_count += 1; float flush_unit = wipe_length / flush_count; int flush_idx = 0; for (; flush_idx < flush_count; flush_idx++) {