From ee7ebda584bf474b1ad2edd7858b4c605767872b Mon Sep 17 00:00:00 2001 From: Shantanu Nair Date: Sun, 20 Apr 2025 21:30:10 +0530 Subject: [PATCH] Fixed an issue where the Max Volumetric Speed doesn't consider the Filament Flow Ratio (#9218) * Rework extrusion-per-mm and speed-cap logic to enforce max vol speed * Fix _mm3_per_mm typo --- src/libslic3r/Extruder.hpp | 2 ++ src/libslic3r/GCode.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/Extruder.hpp b/src/libslic3r/Extruder.hpp index f048055456..398d388fd1 100644 --- a/src/libslic3r/Extruder.hpp +++ b/src/libslic3r/Extruder.hpp @@ -34,7 +34,9 @@ public: double unretract(); double E() const { return m_share_extruder ? m_share_E : m_E; } void reset_E() { m_E = 0.; m_share_E = 0.; } + // e_per_mm is extrusion_per_mm = geometric volume * (filament flow ratio / cross-sectional area) [Doesn't account for print_flow_ratio, or modifiers like bridge flow ratio etc.] double e_per_mm(double mm3_per_mm) const { return mm3_per_mm * m_e_per_mm3; } + // e_per_mm3 is extrusion_per_mm3 = filament flow ratio / cross-sectional area [Doesn't account for print_flow_ratio, or modifiers like bridge flow ratio etc.] double e_per_mm3() const { return m_e_per_mm3; } // Used filament volume in mm^3. double extruded_volume() const; diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 020471033c..5037465574 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -5270,8 +5270,11 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, gcode += m_writer.set_jerk_xy(jerk); } - // calculate extrusion length per distance unit + // calculate effective extrusion length per distance unit (e_per_mm) + double filament_flow_ratio = m_config.option("filament_flow_ratio")->get_at(0); + // We set _mm3_per_mm to effectove flow = Geometric volume * print flow ratio * filament flow ratio * role-based-flow-ratios auto _mm3_per_mm = path.mm3_per_mm * this->config().print_flow_ratio; + _mm3_per_mm *= filament_flow_ratio; if (path.role() == erTopSolidInfill) _mm3_per_mm *= m_config.top_solid_infill_flow_ratio; else if (path.role() == erBottomSurface) @@ -5280,9 +5283,12 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, _mm3_per_mm *= m_config.internal_bridge_flow; else if(sloped) _mm3_per_mm *= m_config.scarf_joint_flow_ratio; - - + // Effective extrusion length per distance unit = (filament_flow_ratio/cross_section) * mm3_per_mm / print flow ratio + // m_writer.extruder()->e_per_mm3() below is (filament flow ratio / cross-sectional area) double e_per_mm = m_writer.extruder()->e_per_mm3() * _mm3_per_mm; + e_per_mm /= filament_flow_ratio; + + // set speed if (speed == -1) {