From 22e76328497ba3d3b746828a8647fd60c0149070 Mon Sep 17 00:00:00 2001 From: lertlmaier Date: Fri, 25 Jul 2025 09:13:12 +0200 Subject: [PATCH] =?UTF-8?q?Makierung=20der=20Drehrichtung=20der=20Kreisel?= =?UTF-8?q?=20mit=20neuem=20Symbol=20hinzugef=C3=BCgt.=20=C3=9Cbergabe=20d?= =?UTF-8?q?er=20Information=20im=20Json-String=20via=20"Drehrichtung:=20UZ?= =?UTF-8?q?S=20/=20GUZS"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plant2dxf.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/lib/plant2dxf.py b/lib/plant2dxf.py index 88a18d3..163dbc0 100644 --- a/lib/plant2dxf.py +++ b/lib/plant2dxf.py @@ -1,8 +1,6 @@ """ placeblocks.py Erzeugt DXF-Elemente aus einer RuleDesigner-CSV. -Einfache Formen (z.B. "ILS 2.0 Kreisel") werden direkt konstruiert, -komplexe per Blockreferenz aus einer DXF-Bibliothek eingefügt. """ import os @@ -145,6 +143,7 @@ def handle_ils_2_0_kreisel(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, f"({pos[0]:.1f}, {pos[1]:.1f}), rot={rotation}") # Linien zeichnen draw_kreisel_lines(msp, pos1, pos2) + draw_kreisel_drehrichtung_markierung(msp, pos1, pos2, merkmale, lib_doc, doc, verbose) def draw_kreisel_lines(msp, pos1, pos2): """Zeichnet tangentiale Linien zwischen zwei Kreiselblöcken, unabhängig vom Winkel.""" @@ -169,6 +168,51 @@ def draw_kreisel_lines(msp, pos1, pos2): msp.add_line(p1a, p2a) msp.add_line(p1b, p2b) +def draw_kreisel_drehrichtung_markierung(msp, pos1, pos2, merkmale, lib_doc, doc, verbose): + drehrichtung = merkmale.get("Drehrichtung", "").upper() + if drehrichtung not in ("UZS", "GUZS"): + return + x1, y1 = pos1 + x2, y2 = pos2 + dx = x2 - x1 + dy = y2 - y1 + length = math.hypot(dx, dy) + if length == 0: + return + # Normalenvektor (senkrecht, normiert, Länge = RADIUS) + nx = -dy / length * RADIUS + ny = dx / length * RADIUS + # Obere Linie + p1_oben = (x1 + nx, y1 + ny) + p2_oben = (x2 + nx, y2 + ny) + # Untere Linie + p1_unten = (x1 - nx, y1 - ny) + p2_unten = (x2 - nx, y2 - ny) + # S-LP auf oberer Linie (Drehrichtung wie angegeben) + for i in range(1, 4): + t = i / 4 # 1/4, 2/4, 3/4 + px = p1_oben[0] + t * (p2_oben[0] - p1_oben[0]) + py = p1_oben[1] + t * (p2_oben[1] - p1_oben[1]) + rotation = math.degrees(math.atan2(p2_oben[1] - p1_oben[1], p2_oben[0] - p1_oben[0])) + if drehrichtung == "GUZS": + rotation += 180 + import_block("S-LP", lib_doc, doc) + bref = msp.add_blockref("S-LP", (px, py), dxfattribs={"rotation": rotation}) + if verbose: + print(f"[INFO] Drehrichtung '{drehrichtung}': S-LP oben bei ({px:.1f}, {py:.1f}), rot={rotation:.1f}") + # S-LP auf unterer Linie (Drehrichtung invertiert) + for i in range(1, 4): + t = i / 4 + px = p1_unten[0] + t * (p2_unten[0] - p1_unten[0]) + py = p1_unten[1] + t * (p2_unten[1] - p1_unten[1]) + rotation = math.degrees(math.atan2(p2_unten[1] - p1_unten[1], p2_unten[0] - p1_unten[0])) + if drehrichtung == "UZS": + rotation += 180 + import_block("S-LP", lib_doc, doc) + bref = msp.add_blockref("S-LP", (px, py), dxfattribs={"rotation": rotation}) + if verbose: + print(f"[INFO] Drehrichtung '{drehrichtung}': S-LP unten bei ({px:.1f}, {py:.1f}), rot={rotation:.1f}") + def handle_standard(msp, blocknames, teileid, x, y, lib_doc, doc, verbose): for blockname in blocknames: import_block(blockname, lib_doc, doc)