mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-21 20:25:20 +00:00
Fix issue that per-extruder settings doesn't work properly for non-bbl printers (#11165)
* Automatically generate extruder id & printer extruder variant mappings for non-BBL multi-extruder printers * Support different layer height limit for non-bbl multi-extruder printer
This commit is contained in:
@@ -161,11 +161,18 @@ void extend_default_config_length(DynamicPrintConfig& config, const bool set_nil
|
|||||||
int process_variant_length = default_param_length;
|
int process_variant_length = default_param_length;
|
||||||
int machine_variant_length = default_param_length;
|
int machine_variant_length = default_param_length;
|
||||||
|
|
||||||
|
// Orca: use nozzle/extruder count as the default printer variant length
|
||||||
|
// because non-BBL multi-extruder printers currently do not support extruder variant.
|
||||||
|
if (config.has("nozzle_diameter")) {
|
||||||
|
auto* nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(config.option("nozzle_diameter"));
|
||||||
|
machine_variant_length = nozzle_diameter->values.size();
|
||||||
|
}
|
||||||
|
|
||||||
if(config.has("filament_extruder_variant"))
|
if(config.has("filament_extruder_variant"))
|
||||||
filament_variant_length = config.option<ConfigOptionStrings>("filament_extruder_variant")->size();
|
filament_variant_length = config.option<ConfigOptionStrings>("filament_extruder_variant")->size();
|
||||||
if(config.has("print_extruder_variant"))
|
if(config.has("print_extruder_variant"))
|
||||||
process_variant_length = config.option<ConfigOptionStrings>("print_extruder_variant")->size();
|
process_variant_length = config.option<ConfigOptionStrings>("print_extruder_variant")->size();
|
||||||
if(config.has("printer_extruder_variant"))
|
if(config.has("printer_extruder_variant")) // Use existing variant list if specified, so BBL's multi-variant profiles still works
|
||||||
machine_variant_length = config.option<ConfigOptionStrings>("printer_extruder_variant")->size();
|
machine_variant_length = config.option<ConfigOptionStrings>("printer_extruder_variant")->size();
|
||||||
|
|
||||||
auto replace_nil_and_resize = [&](const std::string & key, int length){
|
auto replace_nil_and_resize = [&](const std::string & key, int length){
|
||||||
|
|||||||
@@ -7996,8 +7996,41 @@ size_t DynamicPrintConfig::get_parameter_size(const std::string& param_name, siz
|
|||||||
return extruder_nums;
|
return extruder_nums;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Orca: Special handling for extruder variants
|
||||||
|
// BBL printers have extruder variants pre-defined in system profiles, however for customized multi-extruder profile,
|
||||||
|
// we need to set up these parameters automatically, otherwise per-extruder options won't work properly.
|
||||||
|
static void extend_extruder_variant(DynamicPrintConfig& config, const unsigned int num_extruders)
|
||||||
|
{
|
||||||
|
// 1. Make sure the `extruder_variant_list` is the same length as extruder cnt
|
||||||
|
auto extruder_variant_opt = dynamic_cast<ConfigOptionStrings*>(config.option("extruder_variant_list"));
|
||||||
|
assert(extruder_variant_opt != nullptr);
|
||||||
|
extruder_variant_opt->resize(num_extruders, extruder_variant_opt); // Use the first option as the default value, so all extruders have the same variant
|
||||||
|
|
||||||
|
// 2. Update `printer_extruder_variant` and `printer_extruder_id` based on `extruder_variant_list`
|
||||||
|
auto printer_extruder_id_opt = dynamic_cast<ConfigOptionInts*>(config.option("printer_extruder_id"));
|
||||||
|
assert(printer_extruder_id_opt != nullptr);
|
||||||
|
printer_extruder_id_opt->values.clear();
|
||||||
|
auto printer_extruder_variant_opt = dynamic_cast<ConfigOptionStrings*>(config.option("printer_extruder_variant"));
|
||||||
|
assert(printer_extruder_variant_opt != nullptr);
|
||||||
|
printer_extruder_variant_opt->values.clear();
|
||||||
|
for (int i = 0; i < num_extruders; i++) {
|
||||||
|
// `extruder_variant_list` specifies supported variant of each nozzle/extruder,
|
||||||
|
// each item is a comma separated list of variants (extruder type + nozzle flow type) this extruder supported
|
||||||
|
std::string variant = extruder_variant_opt->get_at(i);
|
||||||
|
std::vector<std::string> variants_list;
|
||||||
|
boost::split(variants_list, variant, boost::is_any_of(","), boost::token_compress_on);
|
||||||
|
|
||||||
|
if (!variants_list.empty()) {
|
||||||
|
printer_extruder_id_opt->values.insert(printer_extruder_id_opt->values.end(), variants_list.size(), i + 1);
|
||||||
|
printer_extruder_variant_opt->values.insert(printer_extruder_variant_opt->values.end(), variants_list.begin(), variants_list.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DynamicPrintConfig::set_num_extruders(unsigned int num_extruders)
|
void DynamicPrintConfig::set_num_extruders(unsigned int num_extruders)
|
||||||
{
|
{
|
||||||
|
extend_extruder_variant(*this, num_extruders);
|
||||||
|
|
||||||
const auto &defaults = FullPrintConfig::defaults();
|
const auto &defaults = FullPrintConfig::defaults();
|
||||||
for (const std::string &key : print_config_def.extruder_option_keys()) {
|
for (const std::string &key : print_config_def.extruder_option_keys()) {
|
||||||
if (key == "default_filament_profile")
|
if (key == "default_filament_profile")
|
||||||
|
|||||||
@@ -1914,7 +1914,9 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_preset_bundle->get_printer_extruder_count() > 1){
|
// Orca: allow different layer height for non-bbl printers
|
||||||
|
// TODO: allow this for BBL printers too?
|
||||||
|
if (m_preset_bundle->get_printer_extruder_count() > 1 && m_preset_bundle->is_bbl_vendor()) {
|
||||||
int extruder_idx = std::atoi(opt_key.substr(opt_key.find_last_of('#') + 1).c_str());
|
int extruder_idx = std::atoi(opt_key.substr(opt_key.find_last_of('#') + 1).c_str());
|
||||||
if (opt_key.find("min_layer_height") != std::string::npos) {
|
if (opt_key.find("min_layer_height") != std::string::npos) {
|
||||||
auto min_layer_height_from_nozzle = m_preset_bundle->full_config().option<ConfigOptionFloats>("min_layer_height")->values;
|
auto min_layer_height_from_nozzle = m_preset_bundle->full_config().option<ConfigOptionFloats>("min_layer_height")->values;
|
||||||
|
|||||||
Reference in New Issue
Block a user