From 340952299e1706f6d11f86559cce30d716e7ec79 Mon Sep 17 00:00:00 2001 From: lertlmaier Date: Thu, 24 Jul 2025 13:26:39 +0200 Subject: [PATCH] =?UTF-8?q?Optimierung=20der=20Funktion=20`get=5Fshape=5Fc?= =?UTF-8?q?fg`=20zur=20Verarbeitung=20von=20Offsets=20und=20Rotationen=20f?= =?UTF-8?q?=C3=BCr=20Symbole.=20Vereinfachung=20des=20Codes=20durch=20Verw?= =?UTF-8?q?endung=20von=20Schleifen=20zur=20dynamischen=20Erfassung=20von?= =?UTF-8?q?=20Offset-=20und=20Rotationswerten=20aus=20der=20Konfiguration.?= =?UTF-8?q?=20R=C3=BCckgabe=20der=20Symbole=20als=20Liste=20von=20Dictiona?= =?UTF-8?q?ries=20mit=20korrekten=20Offset-=20und=20Rotationswerten.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plant2dxf.py | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/lib/plant2dxf.py b/lib/plant2dxf.py index e150bb4..88a18d3 100644 --- a/lib/plant2dxf.py +++ b/lib/plant2dxf.py @@ -27,33 +27,27 @@ def get_shape_cfg(teileart, cfg_path): # Blöcke items = parser.get(section, "items", fallback="").replace('"', '').split(",") blocks = [item.strip() for item in items if item.strip()] - # Offsets und Rotationen (optional) - offset1 = parser.get(section, "offset_symb1", fallback="0,0") - offset2 = parser.get(section, "offset_symb2", fallback="0,0") - rot1 = parser.get(section, "rot_symb1", fallback="0.0") - rot2 = parser.get(section, "rot_symb2", fallback="0.0") - offsets = [] - for off in (offset1, offset2): - try: - ox, oy = [float(x) for x in off.split(",")] - offsets.append((ox, oy)) - except Exception: - offsets.append((0.0, 0.0)) - rots = [] - for rot in (rot1, rot2): - try: - rots.append(float(rot)) - except Exception: - rots.append(0.0) - # Baue Liste von Dicts symbols = [] for i, name in enumerate(blocks): - sym = { + # Offset + offset_key = f"offset_symb{i+1}" + offset_str = parser.get(section, offset_key, fallback="0,0") + try: + ox, oy = [float(x) for x in offset_str.split(",")] + except Exception: + ox, oy = 0.0, 0.0 + # Rotation + rot_key = f"rot_symb{i+1}" + rot_str = parser.get(section, rot_key, fallback="0.0") + try: + rot = float(rot_str) + except Exception: + rot = 0.0 + symbols.append({ "name": name, - "offset": offsets[i] if i < len(offsets) else (0.0, 0.0), - "rotation": rots[i] if i < len(rots) else 0.0 - } - symbols.append(sym) + "offset": (ox, oy), + "rotation": rot + }) return symbols # --------------------------------------------------------- Konstante Parameter