fix: plate custom name from model_settings.config (plater_name)
Deploy via Portainer / deploy (push) Successful in 0s
Deploy via Portainer / deploy (push) Successful in 0s
This commit is contained in:
@@ -294,6 +294,23 @@ def parse_3mf(file_stream):
|
|||||||
with zipfile.ZipFile(file_stream) as z:
|
with zipfile.ZipFile(file_stream) as z:
|
||||||
names = z.namelist()
|
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) ──────────
|
# ── 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')]
|
slice_info_candidates = [n for n in names if 'slice_info' in n.lower() and n.endswith('.config')]
|
||||||
if slice_info_candidates:
|
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')}
|
meta = {m.get('key'): m.get('value') for m in plate_el.findall('metadata')}
|
||||||
plate['index'] = int(meta.get('index', 0))
|
plate['index'] = int(meta.get('index', 0))
|
||||||
plate['print_time_s'] = int(meta.get('prediction', 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 = []
|
filaments = []
|
||||||
total_g = 0.0
|
total_g = 0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user