Bug fix for perfect name matching

This commit is contained in:
Lam Wei Lun
2026-08-19 16:57:45 +08:00
parent 2e0ef11b0f
commit aeaa3c5d66
6 changed files with 242 additions and 16 deletions
+3 -1
View File
@@ -7252,6 +7252,8 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
entry.filament_id = mat["filament_id"].get<std::string>();
if (mat.contains("setting_id") && mat["setting_id"].is_string())
entry.setting_id = mat["setting_id"].get<std::string>();
if (mat.contains("name") && mat["name"].is_string())
entry.preset_name = mat["name"].get<std::string>();
}
if (m.contains("slot") && m["slot"].is_number_integer())
entry.slot = m["slot"].get<int>();
@@ -16251,7 +16253,7 @@ int Plater::export_published_3mf(const std::vector<std::string>& published_keys,
j.push_back(key);
nlohmann::json jm = nlohmann::json::array();
for (const Slic3r::PublishedMaterialEntry& e : material_keys)
jm.push_back({ {"material", {{"filament_type", e.filament_type}, {"filament_vendor", e.filament_vendor}, {"filament_id", e.filament_id}, {"setting_id", e.setting_id}}}, {"slot", e.slot}, {"keys", e.keys},
jm.push_back({ {"material", {{"filament_type", e.filament_type}, {"filament_vendor", e.filament_vendor}, {"filament_id", e.filament_id}, {"setting_id", e.setting_id}, {"name", e.preset_name}}}, {"slot", e.slot}, {"keys", e.keys},
{"full", e.full}, {"full_keys", e.full_keys},
{"publish_type", e.publish_type}, {"type", e.publish_type_value},
{"publish_color", e.publish_color}, {"color", e.color} });
+6 -3
View File
@@ -924,11 +924,14 @@ std::vector<Slic3r::PublishedMaterialEntry> PublishSettingsDialog::GetPublishedM
entry.filament_id = cat.filament_id;
entry.slot = static_cast<int>(cat.filament_slot);
// The author's preset id distinguishes exact variants that share filament_id
// ("Generic PLA" vs "Generic PLA Matte"), so the receiver can match precisely.
// ("Generic PLA" vs "Generic PLA Matte"), so the receiver can match precisely; the
// preset name is the most direct identity and is matched first on load.
PresetBundle *bundle = wxGetApp().preset_bundle;
if (bundle != nullptr && cat.filament_slot < bundle->filament_presets.size()) {
if (const Preset *preset = bundle->filaments.find_preset(bundle->filament_presets[cat.filament_slot], false, true))
entry.setting_id = preset->setting_id;
if (const Preset *preset = bundle->filaments.find_preset(bundle->filament_presets[cat.filament_slot], false, true)) {
entry.setting_id = preset->setting_id;
entry.preset_name = preset->name;
}
}
// "Full Publish": the whole filament preset is embedded; type and colour are implicitly
// published, and the per-key rows are disabled / their state ignored.