From 0f30e879a831a7e1a2a092c9a9c440f7bb2d656a Mon Sep 17 00:00:00 2001
From: Paul Wolok
Date: Thu, 2 Oct 2025 10:15:01 +0200
Subject: [PATCH] =?UTF-8?q?Man=20kann=20nun=20zwei=20Kreisel=20am=20kreise?=
=?UTF-8?q?l=20mit=20der=20Gef=C3=A4llestrecke=20verbinden=20(aber=20nur?=
=?UTF-8?q?=20zwei=20Kreisel=20noch=20nicht=20ein=20Kreisel=20und=20eine?=
=?UTF-8?q?=20Strecke)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/plant2dxf.py | 91 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 85 insertions(+), 6 deletions(-)
diff --git a/lib/plant2dxf.py b/lib/plant2dxf.py
index 5dced24..0c99585 100644
--- a/lib/plant2dxf.py
+++ b/lib/plant2dxf.py
@@ -283,6 +283,7 @@ def handle_standard(msp, blocknames, teileid, x, y, lib_doc, doc, verbose):
def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, gefaellestrecken_nachbarn,config):
#Vorbereitung der attributen
+ unterschiedlich = False
asoffset = float(config.get("ILS 2.0 Gefällestrecke", "asoffset"))
esoffset = float(config.get("ILS 2.0 Gefällestrecke", "esoffset"))
upper_hoehe_gefaehlle= float(merkmale.get("Höhe oben")) *1000
@@ -302,19 +303,92 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
y1_kreisel = float(gefaellestrecke_nachbarn.get("y1"))
richtung0 = float(gefaellestrecke_nachbarn.get("rotation0"))
richtung1 = float(gefaellestrecke_nachbarn.get("rotation1"))
+ richtung_rad0= math.radians(richtung0)
+ richtung_rad1 = math.radians(richtung1)
+ abstand0 = float(gefaellestrecke_nachbarn.get("abstand0"))
+ abstand1 = float(gefaellestrecke_nachbarn.get("abstand1"))
+ kreisel_verbunden = 0
laenge_m = merkmale.get("Länge in Meter", "10").replace(",", ".")
try:
laenge = float(laenge_m) * 1000 # Meter → mm
except ValueError:
- laenge = 10000 # Fallback 10 m
-
+ laenge = 10000 # F
+
+
+ #ausrechnung position kreisel
+ halbabstand0 = abstand0 / 2
+ dx0 = halbabstand0 * math.cos(richtung_rad0)
+ dy0 = halbabstand0 * math.sin(richtung_rad0)
+ pos0_0 = (round(x0_kreisel - dx0),round( y0_kreisel - dy0),hoehe0)
+ pos0_1 = (round(x0_kreisel+ dx0),round( y0_kreisel+ dy0), hoehe0)
+
+ halbabstand1 = abstand1 / 2
+ dx1 = halbabstand1 * math.cos(richtung_rad1)
+ dy1 = halbabstand1 * math.sin(richtung_rad1)
+ pos1_0 = (round(x1_kreisel - dx1), round(y1_kreisel - dy1), hoehe1)
+ pos1_1 = (round(x1_kreisel + dx1), round(y1_kreisel + dy1), hoehe1)
+ winkel = math.radians(float(merkmale.get("Drehung")))
+
+ halbe_laenge = laenge / 2
+ dx = halbe_laenge *math.sin(winkel * -1)
+ dy = halbe_laenge * math.cos(winkel)
+ start = (x +dx , y + dy ,upper_hoehe_gefaehlle)
+ ende = (x -dx, y - dy ,lower_hoehe_gefaehlle)
+ abstand_fuer_kreis_start = round(start[0] +RADIUS),round( start[1] + RADIUS)
+ abstand_gegen_kreis_start = round(start[0] - RADIUS), round(start[1] - RADIUS)
+ abstand_fuer_kreis_ende = round(ende[0] + RADIUS), round(ende[1] + RADIUS)
+ abstand_gegen_kreis_ende = round(ende[0] - RADIUS), round(ende[1] - RADIUS)
+
+
+ if( abstand_fuer_kreis_start[0] == pos0_0[0] or abstand_fuer_kreis_start[0] == pos0_1[0] or
+ abstand_fuer_kreis_start[1] == pos0_0[1] or abstand_fuer_kreis_start[1] == pos0_1[1] or
+ abstand_gegen_kreis_ende[0] == pos0_0[0] or abstand_gegen_kreis_ende[0] == pos0_1[0] or
+ abstand_gegen_kreis_ende[1] == pos0_0[1] or abstand_gegen_kreis_ende[1] == pos0_1[1]
+
+
+
+ ):
+ kreisel_verbunden = kreisel_verbunden +1
+
+
+
+ if ( abstand_gegen_kreis_start[0] == pos1_0[0] or abstand_gegen_kreis_start[0] == pos1_1[0] or
+ abstand_gegen_kreis_start[1] == pos1_0[1] or abstand_gegen_kreis_start[1] == pos1_1[1]or
+ abstand_fuer_kreis_ende[0] == pos1_0[0] or abstand_fuer_kreis_ende[0] == pos1_1[0] or
+ abstand_fuer_kreis_ende[1] == pos1_0[1] or abstand_fuer_kreis_ende[1] == pos1_1[1]
+ ):
+ kreisel_verbunden = kreisel_verbunden +1
+
+ if kreisel_verbunden == 2:
+ msp.add_line(start,ende)
+ return
+
+
+ if richtung0 == 90.0 or richtung0 ==270:
+ richtung0= "Vertikal"
+ else:
+ richtung0 = "Horinzontal"
+ if richtung1 == 90.0 or richtung1 ==270:
+ richtung1= "Vertikal"
+ else:
+ richtung1 = "Horinzontal"
+
+
+
+
+ if (richtung0 != richtung1):
+ if x-RADIUS == x0_kreisel or x+RADIUS == x0_kreisel or x-RADIUS == x1_kreisel or x+ RADIUS == x1_kreisel:
+ richtung0= "Horinzontal"
+ else:
+ richtung1 = "Vertikal"
+ unterschiedlich = True
#Berechnung des Gefälles
if hoehe0 > hoehe1:
hight_position = "higher"
else:
hight_position = "lower"
- if richtung0 == 90.0 or richtung0 == 270.0:
+ if richtung0 == "Vertikal":
if x0_kreisel < x1_kreisel:
position = hight_position + "_links"
else:
@@ -325,12 +399,12 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
else:
position = hight_position + "_lower"
- if richtung0 == 90.0 or richtung0 == 270.0:
+ if richtung0 == "Vertikal":
if position == "lower_rechts" or position == "higher_links":
gefaelle = "links"
else:
gefaelle = "rechts"
- elif richtung0 == 0.0 or richtung0 == 180.0:
+ elif richtung0 == "Horinzontal":
if position == "lower_lower" or position == "higher_higher":
gefaelle = "oben"
else:
@@ -598,7 +672,10 @@ def get_rotations_of_gefaellestrecke(csv_path:Path) -> dict:
drehung = merkmale.get("Drehrichtung")
rotation = merkmale.get("Drehung")
hight = float(merkmale.get("Höhe in m")) *1000
- kreisel.append({"Id":Id, "drehung":drehung, "höhe":hight,"x": x, "y": y, "rotation": rotation})
+ abstand_m = merkmale.get(
+ "Abstand (Kreiselachse A - Kreiselachse) in Meter", "20"
+ ).replace(",", ".")
+ kreisel.append({"Id":Id, "drehung":drehung, "höhe":hight,"x": x, "y": y, "rotation": rotation,"abstand":abstand_m})
for gefaelle in gefaehlleStrecken:
@@ -612,6 +689,7 @@ def get_rotations_of_gefaellestrecke(csv_path:Path) -> dict:
eintrag["x0"] = kreis.get("x")
eintrag["y0"] = kreis.get("y")
eintrag["rotation0"] = kreis.get("rotation")
+ eintrag["abstand0"] = kreis.get("abstand")
anweisungen = 1
elif anweisungen == 1:
eintrag["Drehung1"] = kreis.get("drehung")
@@ -619,6 +697,7 @@ def get_rotations_of_gefaellestrecke(csv_path:Path) -> dict:
eintrag["x1"] = kreis.get("x")
eintrag["y1"] = kreis.get("y")
eintrag["rotation1"] = kreis.get("rotation")
+ eintrag["abstand1"] = kreis.get("abstand")
break
gefaellestrecken_nachbarn.append(eintrag)