From 9e2f227aef521147aedd20b09c3527e8125d878b Mon Sep 17 00:00:00 2001 From: "salt.wei" Date: Thu, 8 Sep 2022 11:49:03 +0800 Subject: [PATCH] ENH: fix wrong extruder offset when loading from gcode All extruder offset should be extruder_offset[0] when it is single extruder multi material. Add handling when load config from gcode. This is fix for github issue #213 Signed-off-by: salt.wei Change-Id: Ia881b2bfbbdffa98e3c3db7b35201dc86b520b29 --- src/libslic3r/GCode/GCodeProcessor.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 9848154d6..edfb73788 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -990,11 +990,22 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) } const ConfigOptionPoints* extruder_offset = config.option("extruder_offset"); + const ConfigOptionBool* single_extruder_multi_material = config.option("single_extruder_multi_material"); if (extruder_offset != nullptr) { - m_extruder_offsets.resize(extruder_offset->values.size()); - for (size_t i = 0; i < extruder_offset->values.size(); ++i) { - Vec2f offset = extruder_offset->values[i].cast(); - m_extruder_offsets[i] = { offset(0), offset(1), 0.0f }; + //BBS: for single extruder multi material, only use the offset of first extruder + if (single_extruder_multi_material != nullptr && single_extruder_multi_material->getBool()) { + Vec2f offset = extruder_offset->values[0].cast(); + m_extruder_offsets.resize(m_result.extruders_count); + for (size_t i = 0; i < m_result.extruders_count; ++i) { + m_extruder_offsets[i] = { offset(0), offset(1), 0.0f }; + } + } + else { + m_extruder_offsets.resize(extruder_offset->values.size()); + for (size_t i = 0; i < extruder_offset->values.size(); ++i) { + Vec2f offset = extruder_offset->values[i].cast(); + m_extruder_offsets[i] = { offset(0), offset(1), 0.0f }; + } } }