fix: plate custom name from model_settings.config (plater_name)
Deploy via Portainer / deploy (push) Successful in 0s

This commit is contained in:
Jo
2026-07-07 10:08:21 +02:00
parent b571a5ef0c
commit 00518c3f3c
+19 -1
View File
@@ -294,6 +294,23 @@ def parse_3mf(file_stream):
with zipfile.ZipFile(file_stream) as z:
names = z.namelist()
# ── 0. Lire les noms custom depuis model_settings.config ────────
# Bambu stocke le nom de plateau dans plater_name (pas dans slice_info)
plater_names = {} # {plate_index: name}
model_settings_candidates = [n for n in names if 'model_settings' in n.lower() and n.endswith('.config')]
if model_settings_candidates:
try:
ms_raw = z.read(model_settings_candidates[0]).decode('utf-8', errors='ignore')
ms_root = ET.fromstring(ms_raw)
for plate_el in ms_root.findall('plate'):
ms_meta = {m.get('key'): m.get('value') for m in plate_el.findall('metadata')}
pid = int(ms_meta.get('plater_id', 0))
pname = ms_meta.get('plater_name', '') or ''
if pid and pname:
plater_names[pid] = pname
except Exception:
pass
# ── 1. Bambu slice_info.config (format XML par plaque) ──────────
slice_info_candidates = [n for n in names if 'slice_info' in n.lower() and n.endswith('.config')]
if slice_info_candidates:
@@ -305,7 +322,8 @@ def parse_3mf(file_stream):
meta = {m.get('key'): m.get('value') for m in plate_el.findall('metadata')}
plate['index'] = int(meta.get('index', 0))
plate['print_time_s'] = int(meta.get('prediction', 0))
plate['name'] = meta.get('name', '') or ''
# Nom custom : priorité à model_settings, fallback sur slice_info
plate['name'] = plater_names.get(plate['index'], '') or meta.get('name', '') or ''
filaments = []
total_g = 0.0