mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-04 22:31:02 +00:00
Apply per-variant cooling, ramming and temperature range on nozzle-rack slices
Fan speeds, multi-tool ramming, the tower interface and flush temperature fallbacks and the custom G-code placeholders now use the extruder variant a filament prints with on each layer, instead of reading by filament id.
This commit is contained in:
+27
-8
@@ -1258,7 +1258,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
config.set_key_value("old_filament_temp", new ConfigOptionInt(old_filament_temp));
|
||||
int interface_temp = full_config.filament_tower_interface_print_temp.get_at(new_filament_id);
|
||||
if (interface_temp == -1)
|
||||
interface_temp = full_config.nozzle_temperature_range_high.get_at(new_filament_id);
|
||||
interface_temp = full_config.nozzle_temperature_range_high.get_at(new_fi);
|
||||
if (full_config.enable_tower_interface_features && tcr.is_contact)
|
||||
new_filament_temp = interface_temp;
|
||||
config.set_key_value("new_filament_temp", new ConfigOptionInt(new_filament_temp));
|
||||
@@ -1309,7 +1309,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
flush_temps[idx] = use_fast_flush ? m_print_config->filament_flush_temp_fast.get_at(fi)
|
||||
: m_print_config->filament_flush_temp.get_at(fi);
|
||||
if (flush_temps[idx] == 0)
|
||||
flush_temps[idx] = m_print_config->nozzle_temperature_range_high.get_at(idx);
|
||||
flush_temps[idx] = m_print_config->nozzle_temperature_range_high.get_at(fi);
|
||||
filament_cooling_before_tower[idx] = m_print_config->filament_cooling_before_tower.get_at(fi);
|
||||
}
|
||||
if (tcr.is_contact || gcodegen.m_layer_index == 0)
|
||||
@@ -1563,7 +1563,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
const bool will_go_down = !is_approx(z, current_z);
|
||||
const bool is_ramming = (gcodegen.config().single_extruder_multi_material) ||
|
||||
(!gcodegen.config().single_extruder_multi_material &&
|
||||
gcodegen.config().filament_multitool_ramming.get_at(tcr.initial_tool));
|
||||
gcodegen.config().filament_multitool_ramming.get_at(gcodegen.get_filament_config_index(tcr.initial_tool)));
|
||||
// Orca: user-facing override (Printer Settings > Wipe tower > "Tool change on wipe tower").
|
||||
// Forces the toolhead to travel over the wipe tower before issuing Tx even on multi-toolhead
|
||||
// printers without ramming, where Orca would otherwise emit Tx in place (potentially over the part).
|
||||
@@ -1620,7 +1620,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
if (gcodegen.config().enable_tower_interface_features && tcr.is_contact) {
|
||||
interface_temp = gcodegen.config().filament_tower_interface_print_temp.get_at(new_extruder_id);
|
||||
if (interface_temp == -1)
|
||||
interface_temp = gcodegen.config().nozzle_temperature_range_high.get_at(new_extruder_id);
|
||||
interface_temp = gcodegen.config().nozzle_temperature_range_high.get_at(gcodegen.get_filament_config_index(new_extruder_id));
|
||||
toolchange_temp_override = interface_temp;
|
||||
}
|
||||
toolchange_gcode_str = gcodegen.set_extruder(new_extruder_id, tcr.print_z, false, toolchange_temp_override,
|
||||
@@ -4342,6 +4342,12 @@ size_t GCode::get_filament_config_index(int filament_id) const
|
||||
return filament_id;
|
||||
}
|
||||
|
||||
size_t GCode::get_filament_config_index(int filament_id, size_t layer_id) const
|
||||
{
|
||||
// Orca: uncached, as the stages after the generator run concurrently with it.
|
||||
return m_print ? m_print->get_filament_config_indx(filament_id, (int) layer_id, false) : filament_id;
|
||||
}
|
||||
|
||||
size_t GCode::get_nozzle_config_index(int filament_id) const
|
||||
{
|
||||
if (m_print) {
|
||||
@@ -9409,10 +9415,13 @@ void GCode::update_placeholder_parser_with_variant_params()
|
||||
|
||||
// Helper: remap config arrays from variant index space to filament_id index space.
|
||||
// After remapping, gcode templates can use param[filament_id] directly.
|
||||
std::vector<size_t> config_index(num_filaments);
|
||||
for (size_t i = 0; i < num_filaments; ++i)
|
||||
config_index[i] = get_filament_config_index(i);
|
||||
auto remap_by_filament = [&](const auto &src) {
|
||||
std::decay_t<decltype(src.values)> dst(num_filaments);
|
||||
for (size_t i = 0; i < num_filaments; ++i)
|
||||
dst[i] = src.get_at(get_filament_config_index(i));
|
||||
dst[i] = src.get_at(config_index[i]);
|
||||
return dst;
|
||||
};
|
||||
|
||||
@@ -9427,6 +9436,16 @@ void GCode::update_placeholder_parser_with_variant_params()
|
||||
this->placeholder_parser().set("first_layer_temperature", new ConfigOptionInts(remap_by_filament(m_config.nozzle_temperature_initial_layer)));
|
||||
this->placeholder_parser().set("pressure_advance", new ConfigOptionFloats(remap_by_filament(m_config.pressure_advance)));
|
||||
this->placeholder_parser().set("enable_pressure_advance", new ConfigOptionBools(remap_by_filament(m_config.enable_pressure_advance)));
|
||||
this->placeholder_parser().set("fan_min_speed", new ConfigOptionFloats(remap_by_filament(m_config.fan_min_speed)));
|
||||
this->placeholder_parser().set("fan_max_speed", new ConfigOptionFloats(remap_by_filament(m_config.fan_max_speed)));
|
||||
this->placeholder_parser().set("additional_cooling_fan_speed", new ConfigOptionInts(remap_by_filament(m_config.additional_cooling_fan_speed)));
|
||||
this->placeholder_parser().set("filament_minimal_purge_on_wipe_tower", new ConfigOptionFloats(remap_by_filament(m_config.filament_minimal_purge_on_wipe_tower)));
|
||||
this->placeholder_parser().set("filament_multitool_ramming", new ConfigOptionBools(remap_by_filament(m_config.filament_multitool_ramming)));
|
||||
this->placeholder_parser().set("filament_multitool_ramming_volume", new ConfigOptionFloats(remap_by_filament(m_config.filament_multitool_ramming_volume)));
|
||||
this->placeholder_parser().set("filament_multitool_ramming_flow", new ConfigOptionFloats(remap_by_filament(m_config.filament_multitool_ramming_flow)));
|
||||
this->placeholder_parser().set("nozzle_temperature_range_low", new ConfigOptionInts(remap_by_filament(m_config.nozzle_temperature_range_low)));
|
||||
const auto nozzle_temperature_range_high = remap_by_filament(m_config.nozzle_temperature_range_high);
|
||||
this->placeholder_parser().set("nozzle_temperature_range_high", new ConfigOptionInts(nozzle_temperature_range_high));
|
||||
|
||||
// --- printer_options_with_variant_1: in m_config these are already merged as filament-indexed ---
|
||||
this->placeholder_parser().set("retraction_distances_when_cut", new ConfigOptionFloats(remap_by_filament(m_config.retraction_distances_when_cut)));
|
||||
@@ -9447,7 +9466,7 @@ void GCode::update_placeholder_parser_with_variant_params()
|
||||
if (flush_v_speed[i] == 0)
|
||||
flush_v_speed[i] = filament_max_v[i];
|
||||
if (flush_temps[i] == 0)
|
||||
flush_temps[i] = m_config.nozzle_temperature_range_high.get_at(i);
|
||||
flush_temps[i] = nozzle_temperature_range_high[i];
|
||||
}
|
||||
this->placeholder_parser().set("flush_volumetric_speeds", new ConfigOptionFloats(flush_v_speed));
|
||||
this->placeholder_parser().set("flush_temperatures", new ConfigOptionInts(flush_temps));
|
||||
@@ -9706,7 +9725,7 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
|
||||
{
|
||||
int interface_temp = m_config.filament_tower_interface_print_temp.get_at(new_filament_id);
|
||||
if (interface_temp == -1)
|
||||
interface_temp = m_config.nozzle_temperature_range_high.get_at(new_filament_id);
|
||||
interface_temp = m_config.nozzle_temperature_range_high.get_at(new_fi);
|
||||
dyn_config.set_key_value("filament_tower_interface_print_temp", new ConfigOptionInt(interface_temp));
|
||||
}
|
||||
if (toolchange_temp_override > 0) {
|
||||
@@ -9745,7 +9764,7 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
|
||||
flush_temps[idx] = use_fast_flush ? m_print->config().filament_flush_temp_fast.get_at(fi)
|
||||
: m_print->config().filament_flush_temp.get_at(fi);
|
||||
if (flush_temps[idx] == 0)
|
||||
flush_temps[idx] = m_print->config().nozzle_temperature_range_high.get_at(idx);
|
||||
flush_temps[idx] = m_print->config().nozzle_temperature_range_high.get_at(fi);
|
||||
filament_cooling_before_tower[idx] = m_print->config().filament_cooling_before_tower.get_at(fi);
|
||||
}
|
||||
std::fill(filament_cooling_before_tower.begin(), filament_cooling_before_tower.end(), 0);
|
||||
|
||||
Reference in New Issue
Block a user