mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-16 07:55:57 +08:00
#375 add previous_layer_z for before_layer_gcode and layer_gcode custom gcode
This commit is contained in:
parent
196c96d818
commit
e37c6d5940
@ -2132,8 +2132,10 @@ void GCode::process_layer(
|
|||||||
std::string gcode;
|
std::string gcode;
|
||||||
|
|
||||||
// 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.
|
||||||
|
coordf_t previous_print_z = m_layer != nullptr ? m_layer->print_z : 0;
|
||||||
if (! print.config().before_layer_gcode.value.empty()) {
|
if (! print.config().before_layer_gcode.value.empty()) {
|
||||||
DynamicConfig config;
|
DynamicConfig config;
|
||||||
|
config.set_key_value("previous_layer_z", new ConfigOptionFloat(previous_print_z));
|
||||||
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));
|
||||||
gcode += this->placeholder_parser_process("before_layer_gcode",
|
gcode += this->placeholder_parser_process("before_layer_gcode",
|
||||||
@ -2144,6 +2146,7 @@ void GCode::process_layer(
|
|||||||
m_layer = &layer;
|
m_layer = &layer;
|
||||||
if (! print.config().layer_gcode.value.empty()) {
|
if (! print.config().layer_gcode.value.empty()) {
|
||||||
DynamicConfig config;
|
DynamicConfig config;
|
||||||
|
config.set_key_value("previous_layer_z", new ConfigOptionFloat(previous_print_z));
|
||||||
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));
|
||||||
gcode += this->placeholder_parser_process("layer_gcode",
|
gcode += this->placeholder_parser_process("layer_gcode",
|
||||||
@ -2516,6 +2519,7 @@ void GCode::process_layer(
|
|||||||
config.set_key_value("previous_extruder", new ConfigOptionInt((int)current_extruder_filament));
|
config.set_key_value("previous_extruder", new ConfigOptionInt((int)current_extruder_filament));
|
||||||
config.set_key_value("next_extruder", new ConfigOptionInt((int)milling_extruder_id));
|
config.set_key_value("next_extruder", new ConfigOptionInt((int)milling_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("previous_layer_z", new ConfigOptionFloat(previous_print_z));
|
||||||
config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
||||||
// Process the start_mill_gcode for the new filament.
|
// Process the start_mill_gcode for the new filament.
|
||||||
gcode += this->placeholder_parser_process("milling_toolchange_start_gcode", start_mill_gcode, current_extruder_filament, &config);
|
gcode += this->placeholder_parser_process("milling_toolchange_start_gcode", start_mill_gcode, current_extruder_filament, &config);
|
||||||
@ -2547,6 +2551,7 @@ void GCode::process_layer(
|
|||||||
config.set_key_value("previous_extruder", new ConfigOptionInt((int)milling_extruder_id));
|
config.set_key_value("previous_extruder", new ConfigOptionInt((int)milling_extruder_id));
|
||||||
config.set_key_value("next_extruder", new ConfigOptionInt((int)current_extruder_filament));
|
config.set_key_value("next_extruder", new ConfigOptionInt((int)current_extruder_filament));
|
||||||
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("previous_layer_z", new ConfigOptionFloat(previous_print_z));
|
||||||
config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
||||||
// Process the end_mill_gcode for the new filament.
|
// Process the end_mill_gcode for the new filament.
|
||||||
gcode += this->placeholder_parser_process("milling_toolchange_start_gcode", end_mill_gcode, current_extruder_filament, &config);
|
gcode += this->placeholder_parser_process("milling_toolchange_start_gcode", end_mill_gcode, current_extruder_filament, &config);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user