mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 03:43:52 +00:00
FIX: remove extra filament change
Jira: none if the fist print filement as same as the filament be set on start gcode not insert filment change Signed-off-by: qing.zhang <qing.zhang@bambulab.com> Change-Id: I0114f287fff9be276a90772537d1910df18dec61 (cherry picked from commit 276c797faff1407b2c1606d4bfafe21773901001)
This commit is contained in:
@@ -6460,6 +6460,9 @@ std::string GCode::retract(bool toolchange, bool is_last_retraction, LiftType li
|
|||||||
|
|
||||||
std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bool by_object)
|
std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bool by_object)
|
||||||
{
|
{
|
||||||
|
//init extrude
|
||||||
|
m_writer.init_extruder(new_filament_id);
|
||||||
|
|
||||||
int new_extruder_id = get_extruder_id(new_filament_id);
|
int new_extruder_id = get_extruder_id(new_filament_id);
|
||||||
if (!m_writer.need_toolchange(new_filament_id))
|
if (!m_writer.need_toolchange(new_filament_id))
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -994,6 +994,15 @@ std::string GCodeWriter::set_extruder(unsigned int filament_id)
|
|||||||
return this->need_toolchange(filament_id) ? this->toolchange(filament_id) : "";
|
return this->need_toolchange(filament_id) ? this->toolchange(filament_id) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GCodeWriter::init_extruder(unsigned int filament_id)
|
||||||
|
{
|
||||||
|
if (m_curr_extruder_id == -1 && filament_id != -1) {
|
||||||
|
auto filament_extruder_iter = Slic3r::lower_bound_by_predicate(m_filament_extruders.begin(), m_filament_extruders.end(), [filament_id](const Extruder &e) { return e.id() < filament_id; });
|
||||||
|
assert(filament_extruder_iter != m_filament_extruders.end() && filament_extruder_iter->id() == filament_id);
|
||||||
|
m_curr_extruder_id = filament_extruder_iter->extruder_id();
|
||||||
|
m_curr_filament_extruder[m_curr_extruder_id] = &*filament_extruder_iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool GCodeWriter::need_toolchange(unsigned int filament_id)const
|
bool GCodeWriter::need_toolchange(unsigned int filament_id)const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public:
|
|||||||
// return false if this extruder was already selected
|
// return false if this extruder was already selected
|
||||||
bool need_toolchange(unsigned int filament_id) const;
|
bool need_toolchange(unsigned int filament_id) const;
|
||||||
std::string set_extruder(unsigned int filament_id);
|
std::string set_extruder(unsigned int filament_id);
|
||||||
|
void init_extruder(unsigned int filament_id);
|
||||||
// Prefix of the toolchange G-code line, to be used by the CoolingBuffer to separate sections of the G-code
|
// Prefix of the toolchange G-code line, to be used by the CoolingBuffer to separate sections of the G-code
|
||||||
// printed with the same extruder.
|
// printed with the same extruder.
|
||||||
std::string toolchange_prefix() const;
|
std::string toolchange_prefix() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user