Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::ProcessLayer Namespace Reference

Functions

static std::string emit_custom_gcode_per_print_z (GCode &gcodegen, const CustomGCode::Item *custom_gcode, unsigned int current_extruder_id, unsigned int first_extruder_id, const PrintConfig &config)
 

Function Documentation

◆ emit_custom_gcode_per_print_z()

static std::string Slic3r::ProcessLayer::emit_custom_gcode_per_print_z ( GCode gcodegen,
const CustomGCode::Item custom_gcode,
unsigned int  current_extruder_id,
unsigned int  first_extruder_id,
const PrintConfig &  config 
)
static

FIXME_in_fw show message during print pause

FIXME_in_fw show message during print pause

1965 {
1966 std::string gcode;
1967 bool single_extruder_printer = config.nozzle_diameter.size() == 1;
1968
1969 if (custom_gcode != nullptr) {
1970 // Extruder switches are processed by LayerTools, they should be filtered out.
1971 assert(custom_gcode->type != CustomGCode::ToolChange);
1972
1973 CustomGCode::Type gcode_type = custom_gcode->type;
1974 bool color_change = gcode_type == CustomGCode::ColorChange;
1975 bool tool_change = gcode_type == CustomGCode::ToolChange;
1976 // Tool Change is applied as Color Change for a single extruder printer only.
1977 assert(! tool_change || single_extruder_printer);
1978
1979 std::string pause_print_msg;
1980 int m600_extruder_before_layer = -1;
1981 if (color_change && custom_gcode->extruder > 0)
1982 m600_extruder_before_layer = custom_gcode->extruder - 1;
1983 else if (gcode_type == CustomGCode::PausePrint)
1984 pause_print_msg = custom_gcode->extra;
1985
1986 // we should add or not colorprint_change in respect to nozzle_diameter count instead of really used extruders count
1987 if (color_change || tool_change)
1988 {
1989 assert(m600_extruder_before_layer >= 0);
1990 // Color Change or Tool Change as Color Change.
1991 // add tag for processor
1992 gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Color_Change) + ",T" + std::to_string(m600_extruder_before_layer) + "," + custom_gcode->color + "\n";
1993
1994 if (!single_extruder_printer && m600_extruder_before_layer >= 0 && first_extruder_id != (unsigned)m600_extruder_before_layer
1995 // && !MMU1
1996 ) {
1998 // FIXME: Why is pause_print_gcode here? Why is it supplied "color_change_extruder"? Why is that not
1999 // passed to color_change_gcode below?
2000 DynamicConfig cfg;
2001 cfg.set_key_value("color_change_extruder", new ConfigOptionInt(m600_extruder_before_layer));
2002 gcode += gcodegen.placeholder_parser_process("pause_print_gcode", config.pause_print_gcode, current_extruder_id, &cfg);
2003 gcode += "\n";
2004 gcode += "M117 Change filament for Extruder " + std::to_string(m600_extruder_before_layer) + "\n";
2005 }
2006 else {
2007 gcode += gcodegen.placeholder_parser_process("color_change_gcode", config.color_change_gcode, current_extruder_id);
2008 gcode += "\n";
2009 //FIXME Tell G-code writer that M600 filled the extruder, thus the G-code writer shall reset the extruder to unretracted state after
2010 // return from M600. Thus the G-code generated by the following line is ignored.
2011 // see GH issue #6362
2012 gcodegen.writer().unretract();
2013 }
2014 }
2015 else {
2016 if (gcode_type == CustomGCode::PausePrint) // Pause print
2017 {
2018 // add tag for processor
2019 gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Pause_Print) + "\n";
2021 if (!pause_print_msg.empty())
2022 gcode += "M117 " + pause_print_msg + "\n";
2023 gcode += gcodegen.placeholder_parser_process("pause_print_gcode", config.pause_print_gcode, current_extruder_id);
2024 }
2025 else {
2026 // add tag for processor
2027 gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Custom_Code) + "\n";
2028 if (gcode_type == CustomGCode::Template) // Template Custom Gcode
2029 gcode += gcodegen.placeholder_parser_process("template_custom_gcode", config.template_custom_gcode, current_extruder_id);
2030 else // custom Gcode
2031 gcode += custom_gcode->extra;
2032
2033 }
2034 gcode += "\n";
2035 }
2036 }
2037
2038 return gcode;
2039 }
Definition Config.hpp:720
Definition Config.hpp:2323
bool set_key_value(const std::string &opt_key, ConfigOption *opt)
Definition Config.hpp:2431
std::string placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override=nullptr)
Definition GCode.cpp:1683
GCodeWriter & writer()
Definition GCode.hpp:174
std::string unretract()
Definition GCodeWriter.cpp:435
Type
Definition CustomGCode.hpp:14
std::string extra
Definition CustomGCode.hpp:42
int extruder
Definition CustomGCode.hpp:37
Type type
Definition CustomGCode.hpp:36
std::string color
Definition CustomGCode.hpp:40

References Slic3r::CustomGCode::Item::color, Slic3r::GCodeProcessor::Color_Change, Slic3r::CustomGCode::ColorChange, Slic3r::GCodeProcessor::Custom_Code, Slic3r::CustomGCode::Item::extra, Slic3r::CustomGCode::Item::extruder, Slic3r::GCodeProcessor::Pause_Print, Slic3r::CustomGCode::PausePrint, Slic3r::GCode::placeholder_parser_process(), Slic3r::GCodeProcessor::reserved_tag(), Slic3r::DynamicConfig::set_key_value(), Slic3r::CustomGCode::Template, Slic3r::CustomGCode::ToolChange, Slic3r::CustomGCode::Item::type, Slic3r::GCodeWriter::unretract(), and Slic3r::GCode::writer().

Referenced by Slic3r::GCode::process_layer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: