Makierung der Drehrichtung der Kreisel mit neuem Symbol hinzugefügt. Übergabe der Information im Json-String via "Drehrichtung: UZS / GUZS"
This commit is contained in:
+46
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user