OrcaSlicer latest
OrcaSlicer
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()

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

5676 {
5677 std::string gcode;
5678 // BBS
5679 bool single_filament_print = config.filament_diameter.size() == 1;
5680
5681 if (custom_gcode != nullptr) {
5682 // Extruder switches are processed by LayerTools, they should be filtered out.
5683 assert(custom_gcode->type != CustomGCode::ToolChange);
5684
5685 CustomGCode::Type gcode_type = custom_gcode->type;
5686 bool color_change = gcode_type == CustomGCode::ColorChange;
5687 bool tool_change = gcode_type == CustomGCode::ToolChange;
5688 // Tool Change is applied as Color Change for a single extruder printer only.
5689 assert(!tool_change || single_filament_print);
5690
5691 std::string pause_print_msg;
5692 int m600_extruder_before_layer = -1;
5693 if (color_change && custom_gcode->extruder > 0)
5694 m600_extruder_before_layer = custom_gcode->extruder - 1;
5695 else if (gcode_type == CustomGCode::PausePrint)
5696 pause_print_msg = custom_gcode->extra;
5697 //BBS: inserting color gcode is removed
5698#if 0
5699 // we should add or not colorprint_change in respect to nozzle_diameter count instead of really used extruders count
5700 if (color_change || tool_change)
5701 {
5702 assert(m600_extruder_before_layer >= 0);
5703 // Color Change or Tool Change as Color Change.
5704 // add tag for processor
5705 gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Color_Change) + ",T" + std::to_string(m600_extruder_before_layer) + "," + custom_gcode->color + "\n";
5706
5707 if (!single_filament_print && m600_extruder_before_layer >= 0 && first_extruder_id != (unsigned)m600_extruder_before_layer
5708 // && !MMU1
5709 ) {
5711 DynamicConfig cfg;
5712 cfg.set_key_value("color_change_extruder", new ConfigOptionInt(m600_extruder_before_layer));
5713 gcode += gcodegen.placeholder_parser_process("machine_pause_gcode", config.machine_pause_gcode, current_extruder_id, &cfg);
5714 gcode += "\n";
5715 gcode += "M117 Change filament for Extruder " + std::to_string(m600_extruder_before_layer) + "\n";
5716 }
5717 else {
5718 gcode += gcodegen.placeholder_parser_process("color_change_gcode", config.color_change_gcode, current_extruder_id);
5719 gcode += "\n";
5720 //FIXME Tell G-code writer that M600 filled the extruder, thus the G-code writer shall reset the extruder to unretracted state after
5721 // return from M600. Thus the G-code generated by the following line is ignored.
5722 // see GH issue #6362
5723 gcodegen.writer().unretract();
5724 }
5725 }
5726 else {
5727#endif
5728 if (gcode_type == CustomGCode::PausePrint) // Pause print
5729 {
5730 // add tag for processor
5733 //if (!pause_print_msg.empty())
5734 // gcode += "M117 " + pause_print_msg + "\n";
5735 gcode += gcodegen.placeholder_parser_process("machine_pause_gcode", config.machine_pause_gcode, current_extruder_id) + "\n";
5736 }
5737 else {
5738 // add tag for processor
5740 if (gcode_type == CustomGCode::Template) // Template Custom Gcode
5741 gcode += gcodegen.placeholder_parser_process("template_custom_gcode", config.template_custom_gcode, current_extruder_id);
5742 else // custom Gcode
5743 gcode += custom_gcode->extra;
5744
5745 }
5746 gcode += "\n";
5747#if 0
5748 }
5749#endif
5750 }
5751
5752 return gcode;
5753 }
Definition Config.hpp:1019
Definition Config.hpp:2910
bool set_key_value(const std::string &opt_key, ConfigOption *opt)
Definition Config.hpp:3022
static const std::string & reserved_tag(ETags tag)
Definition GCodeProcessor.hpp:636
@ Color_Change
Definition GCodeProcessor.hpp:610
@ Pause_Print
Definition GCodeProcessor.hpp:611
@ Custom_Code
Definition GCodeProcessor.hpp:612
std::string unretract(float extra_retract=0.f)
Definition GCodeWriter.cpp:1510
std::string placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_filament_id, const DynamicConfig *config_override=nullptr)
Definition GCode.cpp:5319
GCodeWriter & writer()
Definition GCode.hpp:287
Type
Definition CustomGCode.hpp:18
@ PausePrint
Definition CustomGCode.hpp:20
@ ToolChange
Definition CustomGCode.hpp:21
@ Template
Definition CustomGCode.hpp:22
@ ColorChange
Definition CustomGCode.hpp:19
@ gcode
Definition Time.hpp:14
std::string extra
Definition CustomGCode.hpp:47
int extruder
Definition CustomGCode.hpp:42
Type type
Definition CustomGCode.hpp:41
std::string color
Definition CustomGCode.hpp:45

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: