Fix of "MM incorrect extruder temperature"

https://github.com/prusa3d/Slic3r/issues/443

Change of the PlaceholderParser:
All vector configuration values stored into the PlaceholderParser
are expected to be addressed by the extruder ID, therefore
if a vector configuration value is addressed without an index,
a current extruder ID is used.

Also a small fix of fan handling: The fan speed is set to zero
at the start of the G-code if the cooling for the initial extruder
is disabled.
This commit is contained in:
bubnikv 2017-07-31 15:42:55 +02:00
parent 7181f5d163
commit 75c72bc59b
5 changed files with 80 additions and 69 deletions

View file

@ -469,7 +469,7 @@ bool GCode::do_export(FILE *file, Print &print)
m_cooling_buffer->set_current_extruder(initial_extruder_id);
// Disable fan.
if (print.config.cooling.get_at(initial_extruder_id) && print.config.disable_fan_first_layers.get_at(initial_extruder_id))
if (! print.config.cooling.get_at(initial_extruder_id) || print.config.disable_fan_first_layers.get_at(initial_extruder_id))
write(file, m_writer.set_fan(0, true));
// Set bed temperature if the start G-code does not contain any bed temp control G-codes.
@ -487,10 +487,12 @@ bool GCode::do_export(FILE *file, Print &print)
this->_print_first_layer_extruder_temperatures(file, print, initial_extruder_id, false);
// Let the start-up script prime the 1st printing tool.
m_placeholder_parser.set("initial_tool", initial_extruder_id);
writeln(file, m_placeholder_parser.process(print.config.start_gcode.value));
m_placeholder_parser.set("initial_extruder", initial_extruder_id);
m_placeholder_parser.set("current_extruder", initial_extruder_id);
writeln(file, m_placeholder_parser.process(print.config.start_gcode.value, initial_extruder_id));
// Process filament-specific gcode in extruder order.
for (const std::string &start_gcode : print.config.start_filament_gcode.values)
writeln(file, m_placeholder_parser.process(start_gcode));
writeln(file, m_placeholder_parser.process(start_gcode, &start_gcode - &print.config.start_filament_gcode.values.front()));
this->_print_first_layer_extruder_temperatures(file, print, initial_extruder_id, true);
// Set other general things.
@ -636,8 +638,8 @@ bool GCode::do_export(FILE *file, Print &print)
write(file, m_writer.set_fan(false));
// Process filament-specific gcode in extruder order.
for (const std::string &end_gcode : print.config.end_filament_gcode.values)
writeln(file, m_placeholder_parser.process(end_gcode));
writeln(file, m_placeholder_parser.process(print.config.end_gcode));
writeln(file, m_placeholder_parser.process(end_gcode, &end_gcode - &print.config.end_filament_gcode.values.front()));
writeln(file, m_placeholder_parser.process(print.config.end_gcode, m_writer.extruder()->id()));
write(file, m_writer.update_progress(m_layer_count, m_layer_count, true)); // 100%
write(file, m_writer.postamble());
@ -800,7 +802,7 @@ void GCode::process_layer(
PlaceholderParser pp(m_placeholder_parser);
pp.set("layer_num", m_layer_index + 1);
pp.set("layer_z", print_z);
gcode += pp.process(print.config.before_layer_gcode.value) + "\n";
gcode += pp.process(print.config.before_layer_gcode.value, m_writer.extruder()->id()) + "\n";
}
gcode += this->change_layer(print_z); // this will increase m_layer_index
m_layer = &layer;
@ -808,7 +810,7 @@ void GCode::process_layer(
PlaceholderParser pp(m_placeholder_parser);
pp.set("layer_num", m_layer_index);
pp.set("layer_z", print_z);
gcode += pp.process(print.config.layer_gcode.value) + "\n";
gcode += pp.process(print.config.layer_gcode.value, m_writer.extruder()->id()) + "\n";
}
if (! first_layer && ! m_second_layer_things_done) {
@ -2004,7 +2006,7 @@ std::string GCode::set_extruder(unsigned int extruder_id)
PlaceholderParser pp = m_placeholder_parser;
pp.set("previous_extruder", m_writer.extruder()->id());
pp.set("next_extruder", extruder_id);
gcode += pp.process(m_config.toolchange_gcode.value) + '\n';
gcode += pp.process(m_config.toolchange_gcode.value, extruder_id) + '\n';
}
// if ooze prevention is enabled, park current extruder in the nearest