mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-25 15:47:25 +08:00
Fix of Head crash on completion with sequential printing #5349
In addition to an existing "layer_z" placeholder variable, a new "max_layer_z" has been added to custom G-code sections accumulating maximum of "layer_z" over the print. This value may be used for example in the end G-code of a sequential print to lift the print head up before travel over the whole print bed.
This commit is contained in:
parent
2e73a75951
commit
e62bb4a7c7
@ -360,6 +360,7 @@ namespace Slic3r {
|
|||||||
// Otherwise, leave control to the user completely.
|
// Otherwise, leave control to the user completely.
|
||||||
std::string toolchange_gcode_str;
|
std::string toolchange_gcode_str;
|
||||||
const std::string& toolchange_gcode = gcodegen.config().toolchange_gcode.value;
|
const std::string& toolchange_gcode = gcodegen.config().toolchange_gcode.value;
|
||||||
|
// m_max_layer_z = std::max(m_max_layer_z, tcr.print_z);
|
||||||
if (! toolchange_gcode.empty()) {
|
if (! toolchange_gcode.empty()) {
|
||||||
DynamicConfig config;
|
DynamicConfig config;
|
||||||
int previous_extruder_id = gcodegen.writer().extruder() ? (int)gcodegen.writer().extruder()->id() : -1;
|
int previous_extruder_id = gcodegen.writer().extruder() ? (int)gcodegen.writer().extruder()->id() : -1;
|
||||||
@ -367,6 +368,7 @@ namespace Slic3r {
|
|||||||
config.set_key_value("next_extruder", new ConfigOptionInt((int)new_extruder_id));
|
config.set_key_value("next_extruder", new ConfigOptionInt((int)new_extruder_id));
|
||||||
config.set_key_value("layer_num", new ConfigOptionInt(gcodegen.m_layer_index));
|
config.set_key_value("layer_num", new ConfigOptionInt(gcodegen.m_layer_index));
|
||||||
config.set_key_value("layer_z", new ConfigOptionFloat(tcr.print_z));
|
config.set_key_value("layer_z", new ConfigOptionFloat(tcr.print_z));
|
||||||
|
// config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
|
||||||
toolchange_gcode_str = gcodegen.placeholder_parser_process("toolchange_gcode", toolchange_gcode, new_extruder_id, &config);
|
toolchange_gcode_str = gcodegen.placeholder_parser_process("toolchange_gcode", toolchange_gcode, new_extruder_id, &config);
|
||||||
check_add_eol(toolchange_gcode_str);
|
check_add_eol(toolchange_gcode_str);
|
||||||
}
|
}
|
||||||
@ -1011,11 +1013,12 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
|
|||||||
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
|
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
|
||||||
|
|
||||||
// resets analyzer's tracking data
|
// resets analyzer's tracking data
|
||||||
m_last_height = 0.0f;
|
m_last_height = 0.f;
|
||||||
m_last_layer_z = 0.0f;
|
m_last_layer_z = 0.f;
|
||||||
|
m_max_layer_z = 0.f;
|
||||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||||
m_last_mm3_per_mm = 0.0;
|
m_last_mm3_per_mm = 0.;
|
||||||
m_last_width = 0.0f;
|
m_last_width = 0.f;
|
||||||
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||||
|
|
||||||
// How many times will be change_layer() called?
|
// How many times will be change_layer() called?
|
||||||
@ -1376,6 +1379,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
|
|||||||
DynamicConfig config;
|
DynamicConfig config;
|
||||||
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index));
|
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index));
|
||||||
config.set_key_value("layer_z", new ConfigOptionFloat(m_writer.get_position()(2) - m_config.z_offset.value));
|
config.set_key_value("layer_z", new ConfigOptionFloat(m_writer.get_position()(2) - m_config.z_offset.value));
|
||||||
|
config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
|
||||||
if (print.config().single_extruder_multi_material) {
|
if (print.config().single_extruder_multi_material) {
|
||||||
// Process the end_filament_gcode for the active filament only.
|
// Process the end_filament_gcode for the active filament only.
|
||||||
int extruder_id = m_writer.extruder()->id();
|
int extruder_id = m_writer.extruder()->id();
|
||||||
@ -1877,6 +1881,7 @@ void GCode::process_layer(
|
|||||||
gcode += buf;
|
gcode += buf;
|
||||||
// update caches
|
// update caches
|
||||||
m_last_layer_z = static_cast<float>(print_z);
|
m_last_layer_z = static_cast<float>(print_z);
|
||||||
|
m_max_layer_z = std::max(m_max_layer_z, m_last_layer_z);
|
||||||
m_last_height = height;
|
m_last_height = height;
|
||||||
|
|
||||||
// Set new layer - this will change Z and force a retraction if retract_layer_change is enabled.
|
// Set new layer - this will change Z and force a retraction if retract_layer_change is enabled.
|
||||||
@ -1884,6 +1889,7 @@ void GCode::process_layer(
|
|||||||
DynamicConfig config;
|
DynamicConfig config;
|
||||||
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index + 1));
|
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index + 1));
|
||||||
config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
||||||
|
config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
|
||||||
gcode += this->placeholder_parser_process("before_layer_gcode",
|
gcode += this->placeholder_parser_process("before_layer_gcode",
|
||||||
print.config().before_layer_gcode.value, m_writer.extruder()->id(), &config)
|
print.config().before_layer_gcode.value, m_writer.extruder()->id(), &config)
|
||||||
+ "\n";
|
+ "\n";
|
||||||
@ -1897,6 +1903,7 @@ void GCode::process_layer(
|
|||||||
gcode += this->placeholder_parser_process("layer_gcode",
|
gcode += this->placeholder_parser_process("layer_gcode",
|
||||||
print.config().layer_gcode.value, m_writer.extruder()->id(), &config)
|
print.config().layer_gcode.value, m_writer.extruder()->id(), &config)
|
||||||
+ "\n";
|
+ "\n";
|
||||||
|
config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! first_layer && ! m_second_layer_things_done) {
|
if (! first_layer && ! m_second_layer_things_done) {
|
||||||
@ -2898,6 +2905,7 @@ std::string GCode::set_extruder(unsigned int extruder_id, double print_z)
|
|||||||
config.set_key_value("next_extruder", new ConfigOptionInt((int)extruder_id));
|
config.set_key_value("next_extruder", new ConfigOptionInt((int)extruder_id));
|
||||||
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index));
|
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index));
|
||||||
config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
||||||
|
config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
|
||||||
toolchange_gcode_parsed = placeholder_parser_process("toolchange_gcode", toolchange_gcode, extruder_id, &config);
|
toolchange_gcode_parsed = placeholder_parser_process("toolchange_gcode", toolchange_gcode, extruder_id, &config);
|
||||||
gcode += toolchange_gcode_parsed;
|
gcode += toolchange_gcode_parsed;
|
||||||
check_add_eol(gcode);
|
check_add_eol(gcode);
|
||||||
|
@ -351,6 +351,7 @@ private:
|
|||||||
// Support for G-Code Processor
|
// Support for G-Code Processor
|
||||||
float m_last_height{ 0.0f };
|
float m_last_height{ 0.0f };
|
||||||
float m_last_layer_z{ 0.0f };
|
float m_last_layer_z{ 0.0f };
|
||||||
|
float m_max_layer_z{ 0.0f };
|
||||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||||
double m_last_mm3_per_mm;
|
double m_last_mm3_per_mm;
|
||||||
float m_last_width{ 0.0f };
|
float m_last_width{ 0.0f };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user