mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-08-19 01:05:53 +08:00
ENH: config: refine the object config logic when extruder count changes
1. add logic in CLI 2. add logic to process height range jira: no-jira Change-Id: I8a7ba1a78dacad7131cafa3fb8b742027276c7e8
This commit is contained in:
parent
cc86a62d40
commit
9a6624653b
@ -3344,6 +3344,49 @@ int CLI::run(int argc, char **argv)
|
||||
m_models.emplace_back(std::move(m));
|
||||
}
|
||||
|
||||
|
||||
//update the object config due to extruder count change
|
||||
if ((machine_switch) && (new_extruder_count != current_extruder_count))
|
||||
{
|
||||
//process the object params here
|
||||
size_t num_objects = m_models[0].objects.size();
|
||||
for (int i = 0; i < num_objects; ++i) {
|
||||
ModelObject* object = m_models[0].objects[i];
|
||||
DynamicPrintConfig object_config = object->config.get();
|
||||
if (!object_config.empty()) {
|
||||
if (current_extruder_count < new_extruder_count)
|
||||
object_config.update_values_from_single_to_multi_2(m_print_config, print_options_with_variant);
|
||||
else
|
||||
object_config.update_values_from_multi_to_single_2(print_options_with_variant);
|
||||
object->config.assign_config(std::move(object_config));
|
||||
}
|
||||
for (ModelVolume* v : object->volumes) {
|
||||
if (v->is_model_part() || v->is_modifier()) {
|
||||
DynamicPrintConfig volume_config = v->config.get();
|
||||
if (!volume_config.empty()) {
|
||||
if (current_extruder_count < new_extruder_count)
|
||||
volume_config.update_values_from_single_to_multi_2(m_print_config, print_options_with_variant);
|
||||
else
|
||||
volume_config.update_values_from_multi_to_single_2(print_options_with_variant);
|
||||
v->config.assign_config(std::move(volume_config));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &layer_config_it : object->layer_config_ranges) {
|
||||
ModelConfig& layer_model_config = layer_config_it.second;
|
||||
DynamicPrintConfig layer_config = layer_model_config.get();
|
||||
if (!layer_config.empty()) {
|
||||
if (current_extruder_count < new_extruder_count)
|
||||
layer_config.update_values_from_single_to_multi_2(m_print_config, print_options_with_variant);
|
||||
else
|
||||
layer_config.update_values_from_multi_to_single_2(print_options_with_variant);
|
||||
layer_model_config.assign_config(std::move(layer_config));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//load custom gcodes into model if needed
|
||||
if ((custom_gcodes_map.size() > 0)&&(m_models.size() > 0))
|
||||
{
|
||||
|
@ -4572,7 +4572,7 @@ void Tab::load_current_preset()
|
||||
object->config.assign_config(std::move(object_config));
|
||||
}
|
||||
for (ModelVolume* v : object->volumes) {
|
||||
if (v->is_model_part()) {
|
||||
if (v->is_model_part() || v->is_modifier()) {
|
||||
DynamicPrintConfig volume_config = v->config.get();
|
||||
if (!volume_config.empty()) {
|
||||
if (previous_extruder_count < new_extruder_count)
|
||||
@ -4583,6 +4583,18 @@ void Tab::load_current_preset()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &layer_config_it : object->layer_config_ranges) {
|
||||
ModelConfig& layer_model_config = layer_config_it.second;
|
||||
DynamicPrintConfig layer_config = layer_model_config.get();
|
||||
if (!layer_config.empty()) {
|
||||
if (previous_extruder_count < new_extruder_count)
|
||||
layer_config.update_values_from_single_to_multi_2(new_print_config, print_options_with_variant);
|
||||
else
|
||||
layer_config.update_values_from_multi_to_single_2(print_options_with_variant);
|
||||
layer_model_config.assign_config(std::move(layer_config));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user