From 7f480c698d100fd53b45d87a2a16afddc7e21487 Mon Sep 17 00:00:00 2001 From: Nicolas Predella Date: Fri, 22 May 2026 11:25:07 +0300 Subject: [PATCH] naming --- infra/networking/gcode_utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/infra/networking/gcode_utils.py b/infra/networking/gcode_utils.py index 4a75730..2c182d9 100644 --- a/infra/networking/gcode_utils.py +++ b/infra/networking/gcode_utils.py @@ -39,12 +39,20 @@ def parse_gcode_metadata(gcode: str) -> dict[str, Any]: def get_gcode_name_from_metadata(gcode: str, default: str = "output") -> str: """Generates a descriptive name for the G-code based on its objects_info metadata.""" parts_match = re.search(r"; objects_info = (.*)", gcode) + + filament_match = re.search(r"; filament_type = (.*)", gcode) + filament = filament_match[1] if filament_match else '' + + printer_match = re.search(r"; printer_model = (.*)", gcode) + printer = printer_match[1] if printer_match else '' + if parts_match: try: gcode_info = json.loads(parts_match.group(1)) names: list[str] = [str(v['name'].split(" id:")[0]) for v in gcode_info['objects']] counts = Counter(names) - return "-".join(f"{c}x{n}" if c > 1 else n for n, c in counts.items()) + object_names = "-".join(f"{c}x{n}" if c > 1 else n for n, c in counts.items()) + return "-".join([object_names, filament, printer]) except: pass return default