mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 02:22:17 +00:00
ENH: remove the appended T cmd after change filament
Jira: none Signed-off-by: qing.zhang <qing.zhang@bambulab.com> Change-Id: Id5da64626b7343a71dcb38c06f5b5caf43ec40e2 (cherry picked from commit 7da565f0582f470274d279e52daf0dd889f0de7d)
This commit is contained in:
@@ -1447,7 +1447,9 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
|
||||
return;
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("Will export G-code to %1% soon")%path;
|
||||
|
||||
GCodeProcessor::s_IsBBLPrinter = print->is_BBL_printer();
|
||||
m_writer.set_is_bbl_machine(print->is_BBL_printer());
|
||||
print->set_started(psGCodeExport);
|
||||
|
||||
// check if any custom gcode contains keywords used by the gcode processor to
|
||||
@@ -6573,9 +6575,10 @@ std::string GCode::set_extruder(unsigned int extruder_id, double print_z, bool b
|
||||
m_writer.reset_e();
|
||||
}
|
||||
|
||||
// We inform the writer about what is happening, but we may not use the resulting gcode.
|
||||
//BBS: don't add T[next extruder] if there is no T cmd on filament change
|
||||
//We inform the writer about what is happening, but we may not use the resulting gcode.
|
||||
std::string toolchange_command = m_writer.toolchange(extruder_id);
|
||||
if (! custom_gcode_changes_tool(toolchange_gcode_parsed, m_writer.toolchange_prefix(), extruder_id))
|
||||
if (!custom_gcode_changes_tool(toolchange_gcode_parsed, m_writer.toolchange_prefix(), extruder_id))
|
||||
gcode += toolchange_command;
|
||||
else {
|
||||
// user provided his own toolchange gcode, no need to do anything
|
||||
|
||||
@@ -1736,8 +1736,27 @@ void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line, bool
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 5:
|
||||
switch (cmd[1]) {
|
||||
case '1':
|
||||
switch (cmd[2]) {
|
||||
case '0':
|
||||
switch (cmd[3]) {
|
||||
case '2':
|
||||
switch (cmd[4]) {
|
||||
case '0': {
|
||||
process_M1020(line); // Select Tool
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
@@ -3962,6 +3981,42 @@ void GCodeProcessor::process_T(const GCodeReader::GCodeLine& line)
|
||||
process_T(line.cmd());
|
||||
}
|
||||
|
||||
void GCodeProcessor::process_M1020(const GCodeReader::GCodeLine &line)
|
||||
{
|
||||
if (line.raw().length() > 5) {
|
||||
std::string filament_id = line.raw().substr(7);
|
||||
if (filament_id.empty())
|
||||
return;
|
||||
|
||||
int eid = 0;
|
||||
eid = std::stoi(filament_id);
|
||||
if (eid < 0 || eid > 254) {
|
||||
// M1020-1 is a valid gcode line for RepRap Firmwares (used to deselects all tools)
|
||||
if ((m_flavor != gcfRepRapFirmware && m_flavor != gcfRepRapSprinter) || eid != -1)
|
||||
BOOST_LOG_TRIVIAL(error) << "Invalid M1020 command (" << line.raw() << ").";
|
||||
} else {
|
||||
unsigned char id = static_cast<unsigned char>(eid);
|
||||
if (m_extruder_id != id) {
|
||||
if (id >= m_result.extruders_count)
|
||||
BOOST_LOG_TRIVIAL(error) << "Invalid M1020 command (" << line.raw() << ").";
|
||||
else {
|
||||
m_last_extruder_id = m_extruder_id;
|
||||
process_filaments(CustomGCode::ToolChange);
|
||||
m_extruder_id = id;
|
||||
m_cp_color.current = m_extruder_colors[id];
|
||||
// BBS: increase filament change times
|
||||
m_result.lock();
|
||||
m_result.print_statistics.total_filamentchanges++;
|
||||
m_result.unlock();
|
||||
}
|
||||
|
||||
// store tool change move
|
||||
store_move_vertex(EMoveType::Tool_change);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GCodeProcessor::process_T(const std::string_view command)
|
||||
{
|
||||
unsigned int new_extruder = 0;
|
||||
|
||||
@@ -943,6 +943,7 @@ class Print;
|
||||
// Processes T line (Select Tool)
|
||||
void process_T(const GCodeReader::GCodeLine& line);
|
||||
void process_T(const std::string_view command);
|
||||
void process_M1020(const GCodeReader::GCodeLine &line);
|
||||
|
||||
// post process the file with the given filename to:
|
||||
// 1) add remaining time lines M73 and update moves' gcode ids accordingly
|
||||
|
||||
@@ -463,7 +463,11 @@ std::string GCodeWriter::toolchange(unsigned int extruder_id)
|
||||
// if we are running a single-extruder setup, just set the extruder and return nothing
|
||||
std::ostringstream gcode;
|
||||
if (this->multiple_extruders || (this->config.filament_diameter.values.size() > 1 && !is_bbl_printers())) {
|
||||
gcode << this->toolchange_prefix() << extruder_id;
|
||||
// BBS
|
||||
if (this->m_is_bbl_printers)
|
||||
gcode << "M1020 S" << extruder_id;
|
||||
else
|
||||
gcode << this->toolchange_prefix() << extruder_id;
|
||||
//BBS
|
||||
if (GCodeWriter::full_gcode_comment)
|
||||
gcode << " ; change extruder";
|
||||
|
||||
Reference in New Issue
Block a user