diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index f5b0d1c713..3ca75d28f3 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -161,11 +161,18 @@ void extend_default_config_length(DynamicPrintConfig& config, const bool set_nil int process_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(config.option("nozzle_diameter")); + machine_variant_length = nozzle_diameter->values.size(); + } + if(config.has("filament_extruder_variant")) filament_variant_length = config.option("filament_extruder_variant")->size(); if(config.has("print_extruder_variant")) process_variant_length = config.option("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("printer_extruder_variant")->size(); auto replace_nil_and_resize = [&](const std::string & key, int length){ diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 3e48103915..6287e77ceb 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -7996,8 +7996,41 @@ size_t DynamicPrintConfig::get_parameter_size(const std::string& param_name, siz 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(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(config.option("printer_extruder_id")); + assert(printer_extruder_id_opt != nullptr); + printer_extruder_id_opt->values.clear(); + auto printer_extruder_variant_opt = dynamic_cast(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 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) { + extend_extruder_variant(*this, num_extruders); + const auto &defaults = FullPrintConfig::defaults(); for (const std::string &key : print_config_def.extruder_option_keys()) { if (key == "default_filament_profile") diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 377ae13c3f..1f3d73751b 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -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()); if (opt_key.find("min_layer_height") != std::string::npos) { auto min_layer_height_from_nozzle = m_preset_bundle->full_config().option("min_layer_height")->values;