mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 11:23:42 +00:00
Sorry had to re-create the PR as I did some chaos in my repo with CLI. xD Fixes issue https://github.com/OrcaSlicer/OrcaSlicer/issues/10971 Description: Fix wipe tower filament selection and clean up tool ordering. Added wipe_tower_filament handling to WipeTower2 (store config, mark non-selected tools as “soluble,” and use it in toolchange selection) and ensured the configured wipe‑tower extruder is included in the extruder list for ordering. Removed duplicated/merged tool‑ordering code (extra insert_wipe_tower_extruder definition, duplicate declaration, and redundant reorder block) so the tool order logic runs only once. <img width="1819" height="799" alt="image" src="https://github.com/user-attachments/assets/cef39026-cf6a-46da-a87a-ef895774699f" />
This commit is contained in:
@@ -306,6 +306,26 @@ void ToolOrdering::handle_dontcare_extruder(unsigned int last_extruder_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ToolOrdering::insert_wipe_tower_extruder()
|
||||||
|
{
|
||||||
|
if (!m_print_config_ptr || !m_print_config_ptr->enable_prime_tower)
|
||||||
|
return false;
|
||||||
|
if (m_print_config_ptr->wipe_tower_filament == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool changed = false;
|
||||||
|
const unsigned int wipe_extruder = (unsigned int)(m_print_config_ptr->wipe_tower_filament - 1);
|
||||||
|
for (LayerTools < : m_layer_tools) {
|
||||||
|
if (lt.wipe_tower_partitions > 0) {
|
||||||
|
if (std::find(lt.extruders.begin(), lt.extruders.end(), wipe_extruder) == lt.extruders.end()) {
|
||||||
|
lt.extruders.emplace_back(wipe_extruder);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
void ToolOrdering::sort_and_build_data(const Print& print, unsigned int first_extruder, bool prime_multi_material)
|
void ToolOrdering::sort_and_build_data(const Print& print, unsigned int first_extruder, bool prime_multi_material)
|
||||||
{
|
{
|
||||||
// if first extruder is -1, we can decide the first layer tool order before doing reorder function
|
// if first extruder is -1, we can decide the first layer tool order before doing reorder function
|
||||||
@@ -328,9 +348,13 @@ void ToolOrdering::sort_and_build_data(const Print& print, unsigned int first_ex
|
|||||||
|
|
||||||
max_layer_height = calc_max_layer_height(print.config(), max_layer_height);
|
max_layer_height = calc_max_layer_height(print.config(), max_layer_height);
|
||||||
|
|
||||||
this->collect_extruder_statistics(prime_multi_material);
|
|
||||||
|
|
||||||
this->fill_wipe_tower_partitions(print.config(), object_bottom_z, max_layer_height);
|
this->fill_wipe_tower_partitions(print.config(), object_bottom_z, max_layer_height);
|
||||||
|
if (this->insert_wipe_tower_extruder()) {
|
||||||
|
reorder_extruders_for_minimum_flush_volume(reorder_first_layer);
|
||||||
|
this->fill_wipe_tower_partitions(print.config(), object_bottom_z, max_layer_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->collect_extruder_statistics(prime_multi_material);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolOrdering::sort_and_build_data(const PrintObject& object , unsigned int first_extruder, bool prime_multi_material)
|
void ToolOrdering::sort_and_build_data(const PrintObject& object , unsigned int first_extruder, bool prime_multi_material)
|
||||||
@@ -343,9 +367,13 @@ void ToolOrdering::sort_and_build_data(const PrintObject& object , unsigned int
|
|||||||
|
|
||||||
double max_layer_height = calc_max_layer_height(object.print()->config(), object.config().layer_height);
|
double max_layer_height = calc_max_layer_height(object.print()->config(), object.config().layer_height);
|
||||||
|
|
||||||
this->collect_extruder_statistics(prime_multi_material);
|
|
||||||
|
|
||||||
this->fill_wipe_tower_partitions(object.print()->config(), object.layers().front()->print_z - object.layers().front()->height, max_layer_height);
|
this->fill_wipe_tower_partitions(object.print()->config(), object.layers().front()->print_z - object.layers().front()->height, max_layer_height);
|
||||||
|
if (this->insert_wipe_tower_extruder()) {
|
||||||
|
reorder_extruders_for_minimum_flush_volume(reorder_first_layer);
|
||||||
|
this->fill_wipe_tower_partitions(object.print()->config(), object.layers().front()->print_z - object.layers().front()->height, max_layer_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->collect_extruder_statistics(prime_multi_material);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -258,6 +258,7 @@ private:
|
|||||||
void initialize_layers(std::vector<coordf_t> &zs);
|
void initialize_layers(std::vector<coordf_t> &zs);
|
||||||
void collect_extruders(const PrintObject &object, const std::vector<std::pair<double, unsigned int>> &per_layer_extruder_switches);
|
void collect_extruders(const PrintObject &object, const std::vector<std::pair<double, unsigned int>> &per_layer_extruder_switches);
|
||||||
void fill_wipe_tower_partitions(const PrintConfig &config, coordf_t object_bottom_z, coordf_t max_layer_height);
|
void fill_wipe_tower_partitions(const PrintConfig &config, coordf_t object_bottom_z, coordf_t max_layer_height);
|
||||||
|
bool insert_wipe_tower_extruder();
|
||||||
void mark_skirt_layers(const PrintConfig &config, coordf_t max_layer_height);
|
void mark_skirt_layers(const PrintConfig &config, coordf_t max_layer_height);
|
||||||
void collect_extruder_statistics(bool prime_multi_material);
|
void collect_extruder_statistics(bool prime_multi_material);
|
||||||
void reorder_extruders_for_minimum_flush_volume(bool reorder_first_layer);
|
void reorder_extruders_for_minimum_flush_volume(bool reorder_first_layer);
|
||||||
|
|||||||
@@ -1540,7 +1540,7 @@ void WipeTower::set_extruder(size_t idx, const PrintConfig& config)
|
|||||||
m_filpar.push_back(FilamentParameters());
|
m_filpar.push_back(FilamentParameters());
|
||||||
|
|
||||||
m_filpar[idx].material = config.filament_type.get_at(idx);
|
m_filpar[idx].material = config.filament_type.get_at(idx);
|
||||||
m_filpar[idx].is_soluble = config.filament_soluble.get_at(idx);
|
m_filpar[idx].is_soluble = config.wipe_tower_filament == 0 ? config.filament_soluble.get_at(idx) : (idx != size_t(config.wipe_tower_filament - 1));
|
||||||
// BBS
|
// BBS
|
||||||
m_filpar[idx].is_support = config.filament_is_support.get_at(idx);
|
m_filpar[idx].is_support = config.filament_is_support.get_at(idx);
|
||||||
m_filpar[idx].nozzle_temperature = config.nozzle_temperature.get_at(idx);
|
m_filpar[idx].nozzle_temperature = config.nozzle_temperature.get_at(idx);
|
||||||
|
|||||||
@@ -1227,6 +1227,7 @@ WipeTower::ToolChangeResult WipeTower2::construct_tcr(WipeTowerWriter2& writer,
|
|||||||
WipeTower2::WipeTower2(const PrintConfig& config, const PrintRegionConfig& default_region_config,int plate_idx, Vec3d plate_origin, const std::vector<std::vector<float>>& wiping_matrix, size_t initial_tool) :
|
WipeTower2::WipeTower2(const PrintConfig& config, const PrintRegionConfig& default_region_config,int plate_idx, Vec3d plate_origin, const std::vector<std::vector<float>>& wiping_matrix, size_t initial_tool) :
|
||||||
m_semm(config.single_extruder_multi_material.value),
|
m_semm(config.single_extruder_multi_material.value),
|
||||||
m_enable_filament_ramming(config.enable_filament_ramming.value),
|
m_enable_filament_ramming(config.enable_filament_ramming.value),
|
||||||
|
m_wipe_tower_filament(config.wipe_tower_filament.value),
|
||||||
m_wipe_tower_pos(config.wipe_tower_x.get_at(plate_idx), config.wipe_tower_y.get_at(plate_idx)),
|
m_wipe_tower_pos(config.wipe_tower_x.get_at(plate_idx), config.wipe_tower_y.get_at(plate_idx)),
|
||||||
m_wipe_tower_width(float(config.prime_tower_width)),
|
m_wipe_tower_width(float(config.prime_tower_width)),
|
||||||
m_wipe_tower_rotation_angle(float(config.wipe_tower_rotation_angle)),
|
m_wipe_tower_rotation_angle(float(config.wipe_tower_rotation_angle)),
|
||||||
@@ -1309,7 +1310,10 @@ void WipeTower2::set_extruder(size_t idx, const PrintConfig& config)
|
|||||||
m_filpar.push_back(FilamentParameters());
|
m_filpar.push_back(FilamentParameters());
|
||||||
|
|
||||||
m_filpar[idx].material = config.filament_type.get_at(idx);
|
m_filpar[idx].material = config.filament_type.get_at(idx);
|
||||||
m_filpar[idx].is_soluble = config.filament_soluble.get_at(idx);
|
if (m_wipe_tower_filament > 0)
|
||||||
|
m_filpar[idx].is_soluble = (idx != size_t(m_wipe_tower_filament - 1));
|
||||||
|
else
|
||||||
|
m_filpar[idx].is_soluble = config.filament_soluble.get_at(idx);
|
||||||
m_filpar[idx].temperature = config.nozzle_temperature.get_at(idx);
|
m_filpar[idx].temperature = config.nozzle_temperature.get_at(idx);
|
||||||
m_filpar[idx].first_layer_temperature = config.nozzle_temperature_initial_layer.get_at(idx);
|
m_filpar[idx].first_layer_temperature = config.nozzle_temperature_initial_layer.get_at(idx);
|
||||||
m_filpar[idx].filament_minimal_purge_on_wipe_tower = config.filament_minimal_purge_on_wipe_tower.get_at(idx);
|
m_filpar[idx].filament_minimal_purge_on_wipe_tower = config.filament_minimal_purge_on_wipe_tower.get_at(idx);
|
||||||
@@ -2224,14 +2228,16 @@ void WipeTower2::save_on_last_wipe()
|
|||||||
int WipeTower2::first_toolchange_to_nonsoluble(
|
int WipeTower2::first_toolchange_to_nonsoluble(
|
||||||
const std::vector<WipeTowerInfo::ToolChange>& tool_changes) const
|
const std::vector<WipeTowerInfo::ToolChange>& tool_changes) const
|
||||||
{
|
{
|
||||||
// Orca: allow calculation of the required depth and wipe volume for soluable toolchanges as well
|
// If a specific wipe tower filament is forced, use it to decide where to finish the layer.
|
||||||
// NOTE: it's not clear if this is the right way, technically we should disable wipe tower if soluble filament is used as it
|
if (m_wipe_tower_filament > 0) {
|
||||||
// will will make the wipe tower unstable. Need to revist this in the future.
|
for (size_t idx = 0; idx < tool_changes.size(); ++idx) {
|
||||||
|
if (!m_filpar[tool_changes[idx].new_tool].is_soluble)
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
// Orca: allow calculation of the required depth and wipe volume for soluble toolchanges as well.
|
||||||
return tool_changes.empty() ? -1 : 0;
|
return tool_changes.empty() ? -1 : 0;
|
||||||
//for (size_t idx=0; idx<tool_changes.size(); ++idx)
|
|
||||||
// if (! m_filpar[tool_changes[idx].new_tool].is_soluble)
|
|
||||||
// return idx;
|
|
||||||
//return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static WipeTower::ToolChangeResult merge_tcr(WipeTower::ToolChangeResult& first,
|
static WipeTower::ToolChangeResult merge_tcr(WipeTower::ToolChangeResult& first,
|
||||||
|
|||||||
@@ -187,6 +187,7 @@ private:
|
|||||||
bool m_semm = true; // Are we using a single extruder multimaterial printer?
|
bool m_semm = true; // Are we using a single extruder multimaterial printer?
|
||||||
bool m_enable_filament_ramming = true;
|
bool m_enable_filament_ramming = true;
|
||||||
bool m_is_mk4mmu3 = false;
|
bool m_is_mk4mmu3 = false;
|
||||||
|
int m_wipe_tower_filament = 0; // 1-based config value, 0 means auto
|
||||||
Vec2f m_wipe_tower_pos; // Left front corner of the wipe tower in mm.
|
Vec2f m_wipe_tower_pos; // Left front corner of the wipe tower in mm.
|
||||||
float m_wipe_tower_width; // Width of the wipe tower.
|
float m_wipe_tower_width; // Width of the wipe tower.
|
||||||
float m_wipe_tower_depth = 0.f; // Depth of the wipe tower
|
float m_wipe_tower_depth = 0.f; // Depth of the wipe tower
|
||||||
|
|||||||
@@ -520,6 +520,12 @@ std::vector<unsigned int> Print::extruders(bool conside_custom_gcode) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If a wipe tower filament is explicitly set, ensure it participates in tool ordering.
|
||||||
|
if (has_wipe_tower() && config().wipe_tower_filament != 0 && extruders.size() > 1) {
|
||||||
|
assert(config().wipe_tower_filament > 0 && config().wipe_tower_filament < int(config().nozzle_diameter.size()));
|
||||||
|
extruders.emplace_back(config().wipe_tower_filament - 1); // config value is 1-based
|
||||||
|
}
|
||||||
|
|
||||||
sort_remove_duplicates(extruders);
|
sort_remove_duplicates(extruders);
|
||||||
return extruders;
|
return extruders;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user