From bb7497cf265b17b1dc5bacdfd26f1df7ae5e0d36 Mon Sep 17 00:00:00 2001 From: viewit Date: Tue, 2 Jun 2026 18:33:17 +0200 Subject: [PATCH] fix(preset): filament_id in Preset::save() generieren statt nur in save_current_preset() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Der vorherige Fix griff nur beim Umbenennen. Beim normalen Speichern läuft Preset::save() — dort wird jetzt ebenfalls eine MD5-basierte ID generiert wenn das User-Filament-Preset noch keine hat. --- src/libslic3r/Preset.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 61463dd81f9..60ead0f814f 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -638,6 +638,23 @@ void Preset::save(DynamicPrintConfig* parent_config) //BBS: add project embedded preset logic if (this->is_project_embedded) return; + + // Generate a unique filament_id for user filament presets that don't have one yet. + // Inherited presets (e.g. "My PLA" inheriting "Generic PLA @System") previously had + // no filament_id which caused AMS sync to fall back to the parent's Generic ID. + if (this->is_user() && this->filament_id.empty() && !this->name.empty() && + this->type() == Preset::TYPE_FILAMENT) { + boost::uuids::detail::md5 hash; + boost::uuids::detail::md5::digest_type digest; + hash.process_bytes(this->name.data(), this->name.size()); + hash.get_digest(digest); + const auto char_digest = reinterpret_cast(&digest); + std::string result; + boost::algorithm::hex(char_digest, char_digest + sizeof(boost::uuids::detail::md5::digest_type), std::back_inserter(result)); + this->filament_id = "P" + result.substr(0, 7); + BOOST_LOG_TRIVIAL(info) << "Preset::save: generated filament_id='" << this->filament_id << "' for user preset '" << this->name << "'"; + } + //BBS: change to json format //this->config.save(this->file); std::string from_str;