From 8fbaaf13354939e29b8be1b270ab1bcbf532c541 Mon Sep 17 00:00:00 2001
From: Paul Wolok
Date: Wed, 19 Nov 2025 11:36:39 +0100
Subject: [PATCH] =?UTF-8?q?Vorbereitung=20f=C3=BCr=20die=20Kurven=20f?=
=?UTF-8?q?=C3=BCr=20gef=C3=A4llestrecke=20ergenzung=20von=20=20bogen=209?=
=?UTF-8?q?=20grad=20in=20config,=20jason=20vorbereitung=20f=C3=BCr=20test?=
=?UTF-8?q?=5Ffiles=20jason=20in=20plant2dxf=20ist=20aktuell=20auskommenti?=
=?UTF-8?q?ert=20weil=20es=20die=20dxf=20file=20=C3=A4ndert=20wenn=20es=20?=
=?UTF-8?q?3d=20elemente=20beinflusst?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
cfg/shapes.cfg | 2 +
lib/plant2dxf.py | 308 +++++++++++++++++++++++++++++++++-------------
lib/test_files.py | 33 +++--
3 files changed, 247 insertions(+), 96 deletions(-)
diff --git a/cfg/shapes.cfg b/cfg/shapes.cfg
index 9fedbf7..59ab6c2 100644
--- a/cfg/shapes.cfg
+++ b/cfg/shapes.cfg
@@ -42,6 +42,8 @@ bogen_15_auf = Vario_Bogen_auf_15°
bogen_15_ab = Vario_Bogen_ab_15°
bogen_12_auf = Vario_Bogen_auf_12°
bogen_12_ab = Vario_Bogen_ab_12°
+bogen_9_auf = Vario_Bogen_auf_9°
+bogen_9_ab = Vario_Bogen_ab_9°
bogen_6_auf = Vario_Bogen_auf_6°
bogen_6_ab = Vario_Bogen_ab_6°
bogen_3_auf = Vario_Bogen_auf_3°
diff --git a/lib/plant2dxf.py b/lib/plant2dxf.py
index ceb21f0..bb20d2e 100644
--- a/lib/plant2dxf.py
+++ b/lib/plant2dxf.py
@@ -392,7 +392,8 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
if "6-SP" not in doc.layers:
doc.layers.add(name="6-SP", color=7)
verbunden_am_einen = False
-
+ hat_motor = False
+ hat_umlenk =False
richtung2 ="DEFAULT"
unterschiedlich = False
asoffset = float(config.get("ILS 2.0 Gefällestrecke", "asoffset"))
@@ -400,11 +401,17 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
upper_hoehe_gefaehlle= float(merkmale.get("Höhe oben")) *1000
lower_hoehe_gefaehlle = float(merkmale.get("Höhe unten")) * 1000
hoehe_gefaehlle = (upper_hoehe_gefaehlle + lower_hoehe_gefaehlle)/2
+ laenge_m = merkmale.get("Länge in Meter", "10").replace(",", ".")
+ try:
+ laenge = float(laenge_m) * 1000 # Meter → mm
+ except ValueError:
+ laenge = 10000
for nachbarn in strecken_nachbarn:
if teileid == nachbarn.get("Id"):
gefaellestrecke_nachbarn = nachbarn
break
if "Drehung0" in gefaellestrecke_nachbarn and "Drehung1" not in gefaellestrecke_nachbarn:
+
drehung0 =gefaellestrecke_nachbarn.get("Drehung0")
x0_kreisel = float(gefaellestrecke_nachbarn.get("x0"))
y0_kreisel = float(gefaellestrecke_nachbarn.get("y0"))
@@ -413,11 +420,7 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
richtung0 = float(gefaellestrecke_nachbarn.get("rotation0"))
richtung_rad0= math.radians(richtung0)
abstand0 = float(gefaellestrecke_nachbarn.get("abstand0")) * 1000
- laenge_m = merkmale.get("Länge in Meter", "10").replace(",", ".")
- try:
- laenge = float(laenge_m) * 1000 # Meter → mm
- except ValueError:
- laenge = 10000
+
halbe_laenge = laenge / 2
rotation= float(merkmale.get("Drehung"))
@@ -431,22 +434,67 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
lower_hoehe_gefaehlle = hoehe2
rotation = rotation -180
+ if "kurvenrichtung" in gefaellestrecke_nachbarn:
+ vario_hoehe_0 = float(gefaellestrecke_nachbarn.get("vario_hoehe_0")) * 1000
+ vario_hoehe_1 = float(gefaellestrecke_nachbarn.get("vario_hoehe_1")) * 1000
+ block_Vario_Umlenkstation_500mm ="Vario_Umlenkstation_500mm"
+ block_Vario_Motorstation_500mm = "Vario_Motorstation_500mm"
+ import_block(block_Vario_Umlenkstation_500mm,lib_doc,doc)
+ import_block(block_Vario_Motorstation_500mm,lib_doc,doc)
+ block_Vario_Umlenkstation_500mm =dreh_block(block_Vario_Umlenkstation_500mm,doc,math.radians(3))
+ block_Vario_Motorstation_500mm =dreh_block(block_Vario_Motorstation_500mm,doc,math.radians(3))
+ if upper_hoehe_gefaehlle > lower_hoehe_gefaehlle:
+ if vario_hoehe_0 == upper_hoehe_gefaehlle or vario_hoehe_1 == upper_hoehe_gefaehlle:
+ hat_motor = True
+ else:
+ hat_umlenk = True
+ if upper_hoehe_gefaehlle < lower_hoehe_gefaehlle:
+ if vario_hoehe_0 == lower_hoehe_gefaehlle or vario_hoehe_1 == lower_hoehe_gefaehlle:
+ hat_motor = True
+ else:
+ hat_umlenk = True
+ verbunden_am_einen = True
am_kreisel, kreisel_verbunden =am_kreisel_direct_verbunden(x, y, upper_hoehe_gefaehlle, lower_hoehe_gefaehlle, x0_kreisel, y0_kreisel, richtung_rad0, abstand0, dx, dy, None, None, None, None)
if am_kreisel == 1:
- start = x +dx, y + dy,upper_hoehe_gefaehlle
- ende = x -dx, y - dy,lower_hoehe_gefaehlle
- line =msp.add_line(start,ende)
- line.dxf.layer = "6-SP"
+ if hat_motor == False and hat_umlenk == False:
+ 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
+ line =msp.add_line(start,ende)
+ line.dxf.layer = "6-SP"
- return
-
- verbunden_am_einen = True
+ return
+ else:
+
+ dy = halbe_laenge * math.cos(0)
+ start = [x , y + dy ,upper_hoehe_gefaehlle]
+ ende = [x , y - dy ,lower_hoehe_gefaehlle]
+ blockname = f"Ils_2.0_Gefaellestrecke_{laenge}_{hoehe_gefaehlle}_{hat_umlenk}_{hat_motor}"
+ if blockname not in doc.blocks:
+ block = doc.blocks.new(name=blockname,base_point= (0,0,0))
+ if hat_motor == True:
+ block.add_blockref(block_Vario_Motorstation_500mm, (start[0]-x,start[1] - 250* math.cos(math.radians(3))-y,start[2] - 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
+ start [1]= start[1] - 500* math.cos(math.radians(3))
+ start[2] = start[2] - 500* math.sin(math.radians(3))
+ if hat_umlenk == True:
+ block.add_blockref(block_Vario_Umlenkstation_500mm, (ende[0]-x,ende[1] + 250* math.cos(math.radians(3))-y,ende[2] + 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
+ ende [1]= ende[1] + 500* math.cos(math.radians(3))
+ ende[2] = ende[2] + 500* math.sin(math.radians(3))
+ line = Line.new(dxfattribs={"start":start,"end":ende})
+ line.translate(-x,-y,-hoehe_gefaehlle)
+ block.add_entity(line)
+ msp.add_blockref(blockname,(x,y,hoehe_gefaehlle),dxfattribs={"rotation": rotation})
+ return
if upper_hoehe_gefaehlle == hoehe0:
hight ="higher"
else:
hight = "lower"
-
- blockname = f"Ils_2.0_Gefaellestrecke_{laenge}_{drehung0}_{hoehe_gefaehlle}_{verbunden_am_einen}_{hight}"
+ if hat_motor == False and hat_umlenk == False:
+ blockname = f"Ils_2.0_Gefaellestrecke_{laenge}_{drehung0}_{hoehe_gefaehlle}_{verbunden_am_einen}_{hight}"
+ else:
+ blockname = f"Ils_2.0_Gefaellestrecke_{laenge}_{drehung0}_{hoehe_gefaehlle}_{verbunden_am_einen}_{hight}_{hat_umlenk}_{hat_motor}"
+
if blockname in doc.blocks:
blockref_layer = get_layer(doc, lib_doc, blockname)
bref =msp.add_blockref(blockname,(x,y,hoehe_gefaehlle),dxfattribs={"rotation": rotation, "layer": blockref_layer})
@@ -457,7 +505,22 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
)
a.is_invisible = True
return
- only_es_or_as = erstellung_gefaelle_block_verbunenden_am_einen(msp,x, y, doc, lib_doc, asoffset, esoffset, upper_hoehe_gefaehlle, lower_hoehe_gefaehlle, hoehe_gefaehlle, drehung0, laenge, blockname,hight)
+ block = doc.blocks.new(name=blockname,base_point= (0,0,0))
+
+ dy = halbe_laenge * math.cos(0)
+ start = [x , y + dy ,upper_hoehe_gefaehlle]
+ ende = [x , y - dy ,lower_hoehe_gefaehlle]
+ if hat_motor == True:
+ block.add_blockref(block_Vario_Motorstation_500mm, (start[0]-x,start[1] - 250* math.cos(math.radians(3))-y,start[2] - 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
+ start [1]= start[1] - 500* math.cos(math.radians(3))
+ start[2] = start[2] - 500* math.sin(math.radians(3))
+ if hat_umlenk == True:
+ block.add_blockref(block_Vario_Umlenkstation_500mm, (ende[0]-x,ende[1] + 250* math.cos(math.radians(3))-y,ende[2] + 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
+ ende [1]= ende[1] + 500* math.cos(math.radians(3))
+ ende[2] = ende[2] + 500* math.sin(math.radians(3))
+
+
+ only_es_or_as = erstellung_gefaelle_block_verbunenden_am_einen(msp,x, y, doc, lib_doc, asoffset, esoffset, upper_hoehe_gefaehlle, lower_hoehe_gefaehlle, hoehe_gefaehlle, drehung0, laenge, blockname,hight,None,None,None,block,start,ende)
if only_es_or_as == False:
blockref_layer = get_layer(doc, lib_doc, blockname)
@@ -471,12 +534,6 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
elif "Drehung0" in gefaellestrecke_nachbarn and "Drehung1" in gefaellestrecke_nachbarn:
winkel = math.radians(float(merkmale.get("Drehung")))
-
- laenge_m = merkmale.get("Länge in Meter", "10").replace(",", ".")
- try:
- laenge = float(laenge_m) * 1000 # Meter → mm
- except ValueError:
- laenge = 10000
halbe_laenge = laenge / 2
dx = halbe_laenge *math.sin(winkel * -1)
dy = halbe_laenge * math.cos(winkel)
@@ -626,6 +683,52 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
a.is_invisible = True
#falls eine gefällestrecke nicht mit einem kreisel verbunden ist
else:
+ rotation= float(merkmale.get("Drehung"))
+ if upper_hoehe_gefaehlle < lower_hoehe_gefaehlle:
+ hoehe2 = upper_hoehe_gefaehlle
+ upper_hoehe_gefaehlle = lower_hoehe_gefaehlle
+ lower_hoehe_gefaehlle = hoehe2
+ rotation = rotation -180
+
+
+ if "kurvenrichtung" in gefaellestrecke_nachbarn:
+ vario_hoehe_0 = float(gefaellestrecke_nachbarn.get("vario_hoehe_0")) * 1000
+ vario_hoehe_1 = float(gefaellestrecke_nachbarn.get("vario_hoehe_1")) * 1000
+ block_Vario_Umlenkstation_500mm ="Vario_Umlenkstation_500mm"
+ block_Vario_Motorstation_500mm = "Vario_Motorstation_500mm"
+ import_block(block_Vario_Umlenkstation_500mm,lib_doc,doc)
+ import_block(block_Vario_Motorstation_500mm,lib_doc,doc)
+ block_Vario_Umlenkstation_500mm =dreh_block(block_Vario_Umlenkstation_500mm,doc,math.radians(3))
+ block_Vario_Motorstation_500mm =dreh_block(block_Vario_Motorstation_500mm,doc,math.radians(3))
+ if upper_hoehe_gefaehlle > lower_hoehe_gefaehlle:
+ if vario_hoehe_0 == upper_hoehe_gefaehlle or vario_hoehe_1 == upper_hoehe_gefaehlle:
+ hat_motor = True
+ else:
+ hat_umlenk = True
+ if upper_hoehe_gefaehlle < lower_hoehe_gefaehlle:
+ if vario_hoehe_0 == lower_hoehe_gefaehlle or vario_hoehe_1 == lower_hoehe_gefaehlle:
+ hat_motor = True
+ else:
+ hat_umlenk = True
+ if "kurvenrichtung_1" in gefaellestrecke_nachbarn:
+ vario_hoehe_0_1 = float(gefaellestrecke_nachbarn.get("vario_hoehe_0_1")) * 1000
+ vario_hoehe_1_1 = float(gefaellestrecke_nachbarn.get("vario_hoehe_1_1")) * 1000
+ if upper_hoehe_gefaehlle > lower_hoehe_gefaehlle:
+ if vario_hoehe_0_1 == upper_hoehe_gefaehlle or vario_hoehe_1_1 == upper_hoehe_gefaehlle:
+ hat_motor = True
+ else:
+ hat_umlenk = True
+ if upper_hoehe_gefaehlle < lower_hoehe_gefaehlle:
+ if vario_hoehe_0_1 == lower_hoehe_gefaehlle or vario_hoehe_1_1 == lower_hoehe_gefaehlle:
+ hat_motor = True
+ else:
+ hat_umlenk = True
+ blockname = f"Ils_2.0_Gefaellestrecke_{laenge}_{hoehe_gefaehlle}_{hat_motor}_{hat_umlenk}"
+ halbe_laenge = laenge / 2
+ dy = halbe_laenge * math.cos(0)
+ start = [x , y + dy ,upper_hoehe_gefaehlle]
+ ende = [x , y - dy ,lower_hoehe_gefaehlle]
+ if hat_motor == False and hat_umlenk == False:
laenge_m = merkmale.get("Länge in Meter", "10").replace(",", ".")
try:
laenge = float(laenge_m) * 1000 # Meter → mm
@@ -639,9 +742,40 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
ende = x -dx, y - dy,lower_hoehe_gefaehlle
line = msp.add_line(start,ende)
line.dxf.layer = "6-SP"
-
-
-
+ elif hat_motor == True and hat_umlenk == False:
+ if blockname not in doc.blocks:
+ block = doc.blocks.new(name=blockname,base_point = (0,0,0))
+ block.add_blockref(block_Vario_Motorstation_500mm, (start[0]-x,start[1] - 250* math.cos(math.radians(3))-y,start[2] - 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
+ start [1]= start[1] - 500* math.cos(math.radians(3))
+ start[2] = start[2] - 500* math.sin(math.radians(3))
+ line = Line.new(dxfattribs={"start":start,"end":ende})
+ line.translate(-x,-y,-hoehe_gefaehlle)
+ block.add_entity(line)
+ msp.add_blockref(blockname,(x,y,hoehe_gefaehlle),dxfattribs={"rotation": rotation})
+ elif hat_motor == False and hat_umlenk == True:
+ if blockname not in doc.blocks:
+ block = doc.blocks.new(name=blockname,base_point = (0,0,0))
+ block.add_blockref(block_Vario_Umlenkstation_500mm, (ende[0]-x,ende[1] + 250* math.cos(math.radians(3))-y,ende[2] + 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
+ ende [1]= ende[1] + 500* math.cos(math.radians(3))
+ ende[2] = ende[2] + 500* math.sin(math.radians(3))
+ line = Line.new(dxfattribs={"start":start,"end":ende})
+ line.translate(-x,-y,-hoehe_gefaehlle)
+ block.add_entity(line)
+ msp.add_blockref(blockname,(x,y,hoehe_gefaehlle),dxfattribs={"rotation": rotation})
+ elif hat_motor == True and hat_umlenk == True:
+ if blockname not in doc.blocks:
+ block = doc.blocks.new(name=blockname,base_point = (0,0,0))
+ block.add_blockref(block_Vario_Motorstation_500mm, (start[0]-x,start[1] - 250* math.cos(math.radians(3))-y,start[2] - 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
+ start [1]= start[1] - 500* math.cos(math.radians(3))
+ start[2] = start[2] - 500* math.sin(math.radians(3))
+ block.add_blockref(block_Vario_Umlenkstation_500mm, (ende[0]-x,ende[1] + 250* math.cos(math.radians(3))-y,ende[2] + 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
+ ende [1]= ende[1] + 500* math.cos(math.radians(3))
+ ende[2] = ende[2] + 500* math.sin(math.radians(3))
+ line = Line.new(dxfattribs={"start":start,"end":ende})
+ line.translate(-x,-y,-hoehe_gefaehlle)
+ block.add_entity(line)
+ msp.add_blockref(blockname,(x,y,hoehe_gefaehlle),dxfattribs={"rotation": rotation})
+
def add_attributes_to_block(block, attributes):
"""
Fügt einem bestehenden ezdxf-Block Attribut-Definitionen hinzu.
@@ -661,6 +795,7 @@ def add_attributes_to_block(block, attributes):
a.is_invisible = True
def handle_ils_2_0_variofoerderer(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
+
# für spätere Namens benenung der Vario forderer
motor_vorhanden = bool(merkmale.get("hatMotor"))
umlenk_vorhanden = bool(merkmale.get("hatUmlenkung"))
@@ -1216,17 +1351,13 @@ def handle_omniflo(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols,
drehung = merkmale.get("Drehung")
bref = msp.add_blockref(blockname, (x, y,float(merkmale.get("Höhe"))), dxfattribs={"rotation": drehung})
# Layer, auf dem der Insert liegt
-def erstellung_gefaelle_block_verbunenden_am_einen(msp,x, y, doc, lib_doc, asoffset, esoffset, upper_hoehe_gefaehlle, lower_hoehe_gefaehlle, hoehe_gefaehlle, drehung0, laenge,blockname, hight = None, block_vario = None, vario_richtung = None, verbungden_höher = None):
-
+def erstellung_gefaelle_block_verbunenden_am_einen(msp,x, y, doc, lib_doc, asoffset, esoffset, upper_hoehe_gefaehlle, lower_hoehe_gefaehlle, hoehe_gefaehlle, drehung0, laenge,blockname, hight = None, block_vario = None, vario_richtung = None, verbungden_höher = None,gefaelle_block=None,start = None,ende = None):
halbe_laenge = laenge / 2
dy = halbe_laenge * math.cos(0)
- if ((blockname not in doc.blocks and hight == "higher" and drehung0 == "GUZS" )or (vario_richtung == "Auf"and verbungden_höher == False and drehung0 == "GUZS")or (vario_richtung == "Ab" and verbungden_höher == True and drehung0 == "GUZS") ):
- if hight != None:
- block = doc.blocks.new(name=blockname, base_point=(0,0,0))
+ if (( hight == "higher" and drehung0 == "GUZS" )or (vario_richtung == "Auf"and verbungden_höher == False and drehung0 == "GUZS")or (vario_richtung == "Ab" and verbungden_höher == True and drehung0 == "GUZS") ):
block_as = "200000241_AS-Element_90_rechts"
import_block(block_as,lib_doc,doc)
-
if vario_richtung == "Auf":
start = (x , y + dy ,upper_hoehe_gefaehlle)
ende = (x , y - dy + asoffset ,lower_hoehe_gefaehlle)
@@ -1241,24 +1372,21 @@ def erstellung_gefaelle_block_verbunenden_am_einen(msp,x, y, doc, lib_doc, asoff
# TODO
return start, ende
if laenge > asoffset:
- start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
- ende = (x , y - dy ,lower_hoehe_gefaehlle)
+ start[1] = start[1] - asoffset
line = Line.new(dxfattribs={"start": start, "end": ende})
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_gefaehlle)
- block.add_entity(copy)
- block.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] -hoehe_gefaehlle))
+ gefaelle_block.add_entity(copy)
+ gefaelle_block.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] -hoehe_gefaehlle))
return False
else:
msp.add_blockref(block_as,(x,y,upper_hoehe_gefaehlle))
return True
- elif ((blockname not in doc.blocks and hight == "lower" and drehung0 == "GUZS") or (vario_richtung == "Auf"and verbungden_höher == True and drehung0 == "GUZS") or (vario_richtung == "Ab" and verbungden_höher == False and drehung0 == "GUZS")):
+ elif ((hight == "lower" and drehung0 == "GUZS") or (vario_richtung == "Auf"and verbungden_höher == True and drehung0 == "GUZS") or (vario_richtung == "Ab" and verbungden_höher == False and drehung0 == "GUZS")):
block_es = "200000146_ES-Element_90_rechts"
import_block(block_es,lib_doc,doc)
- if hight != None:
- block = doc.blocks.new(name=blockname, base_point=(0,0,0))
if vario_richtung == "Auf":
start = (x , y + dy-esoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy ,lower_hoehe_gefaehlle)
@@ -1274,28 +1402,23 @@ def erstellung_gefaelle_block_verbunenden_am_einen(msp,x, y, doc, lib_doc, asoff
return start, ende
if laenge > esoffset:
- start = (x , y + dy,upper_hoehe_gefaehlle)
- ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
-
+ ende[1] = ende[1] + esoffset
line = Line.new(dxfattribs={"start": start, "end": ende})
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_gefaehlle)
- block.add_entity(copy)
+ gefaelle_block.add_entity(copy)
- block.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset-y ,ende[2] -hoehe_gefaehlle))
+ gefaelle_block.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset-y ,ende[2] -hoehe_gefaehlle))
return False
else:
msp.add_blockref(block_es,(x,y,lower_hoehe_gefaehlle))
return True
- elif ((blockname not in doc.blocks and hight == "higher" and drehung0 == "UZS")or (vario_richtung == "Auf"and verbungden_höher == False and drehung0 == "UZS") or (vario_richtung == "Ab" and verbungden_höher == True and drehung0 == "UZS")):
+ elif ((hight == "higher" and drehung0 == "UZS")or (vario_richtung == "Auf"and verbungden_höher == False and drehung0 == "UZS") or (vario_richtung == "Ab" and verbungden_höher == True and drehung0 == "UZS")):
block_as = "200000217_AS-Element_90_links"
import_block(block_as,lib_doc,doc)
- if hight != None:
- block = doc.blocks.new(name=blockname, base_point=(0,0,0))
-
if vario_richtung == "Auf":
start = (x , y + dy ,upper_hoehe_gefaehlle)
ende = (x , y - dy + asoffset,lower_hoehe_gefaehlle)
@@ -1312,22 +1435,19 @@ def erstellung_gefaelle_block_verbunenden_am_einen(msp,x, y, doc, lib_doc, asoff
return start, ende
if laenge > asoffset:
- start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
- ende = (x , y - dy ,lower_hoehe_gefaehlle)
+ start[1] = start[1] - asoffset
line = Line.new(dxfattribs={"start": start, "end": ende})
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x ,-y,-hoehe_gefaehlle)
- block.add_entity(copy)
- block.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
+ gefaelle_block.add_entity(copy)
+ gefaelle_block.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
return False
else:
msp.add_blockref(block_as,(x,y,upper_hoehe_gefaehlle),dxfattribs={"rotation": 180})
return True
- elif (( blockname not in doc.blocks and hight == "lower" and drehung0 == "UZS") or (vario_richtung == "Auf" and verbungden_höher == True and drehung0 == "UZS") or (vario_richtung == "Ab" and verbungden_höher == False and drehung0 == "UZS")):
- if hight != None:
- block = doc.blocks.new(name=blockname, base_point=(0,0,0))
+ elif (( hight == "lower" and drehung0 == "UZS") or (vario_richtung == "Auf" and verbungden_höher == True and drehung0 == "UZS") or (vario_richtung == "Ab" and verbungden_höher == False and drehung0 == "UZS")):
block_es = "400102632_ES-Element_90_links"
import_block(block_es,lib_doc,doc)
@@ -1345,14 +1465,13 @@ def erstellung_gefaelle_block_verbunenden_am_einen(msp,x, y, doc, lib_doc, asoff
# TODO
return start, ende
if laenge > esoffset:
- start = (x , y + dy ,upper_hoehe_gefaehlle)
- ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
+ ende[1] = ende[1] + esoffset
line = Line.new(dxfattribs={"start": start, "end": ende})
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x ,-y,-hoehe_gefaehlle)
- block.add_entity(copy)
- block.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset -y,ende[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
+ gefaelle_block.add_entity(copy)
+ gefaelle_block.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset -y,ende[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
return False
else:
msp.add_blockref(block_es,(x,y,lower_hoehe_gefaehlle),dxfattribs={"rotation": 180})
@@ -3045,8 +3164,8 @@ def vario_erstellung(msp,merkmale, x, y, doc, lib_doc, config, winkel, hoehe_var
copy.translate(-x,-y,-hoehe_vario)
block.add_entity(copy)
- #Hilfmethode zur ausmessen der bogen
- # a = msp.add_blockref(block_Vario_ab_9,(x,y,0))
+ # # Hilfmethode zur ausmessen der bogen
+ # a = msp.add_blockref(block_Vario_Bogen_ab_9,(x,y,0))
# msp.add_line((x+1000,y +50,0),(x-1000,y+50,0))
# msp.add_line((x,y+1000,0),(x,y-1000,0))
# add_attributes_to_block(a, ab_9_attrib)
@@ -3220,7 +3339,7 @@ def get_rotations_of_strecken(csv_path:Path) -> dict:
geraden = []
kreisel =[]
strecken_nachbarn = []
- foerderernachbarn = []
+ angetriebene_kurve= []
anweisungen = 0
"""Gib für jede gefällestrecke zurück welche Drehrichtung die benachbarten Kreisel haben """
with csv_path.open(newline="", encoding="utf-8") as fh:
@@ -3252,11 +3371,30 @@ def get_rotations_of_strecken(csv_path:Path) -> dict:
h1 = float(merkmale.get("Höhe Ende")) * 1000
foerderrichtung = merkmale.get("Förderrichtung")
geraden.append({"Id": Id,"NachbarIds":NachbarIds, "Winkel":winkel, "h0": h0,"h1": h1,"Foerderrichtung":foerderrichtung })
-
+ if bezeichner =="ILS 2.0 Kurve angetrieben":
+ Id = row["TeileId"].strip()
+ merkmale = parse_merkmale(row.get("Merkmale", ""))
+ h0 = merkmale.get("Höhe Anfang")
+ h1 = merkmale.get("Höhe Ende")
+ kurvenrichtung = merkmale.get("Kurvenrichtung")
+ angetriebene_kurve.append({"Id": Id,"H0": h0,"H1":h1,"kurvenrichtung":kurvenrichtung})
for gerade in geraden:
anweisungen = 0
+ voerder_anweisung = 0
geraden_anweisung = 0
eintrag = {"Id": gerade["Id"]}
+ for foerderer in angetriebene_kurve:
+ if foerderer["Id"] in gerade["NachbarIds"]:
+ if voerder_anweisung == 0:
+ eintrag["vario_hoehe_0"] = foerderer.get("H0")
+ eintrag["vario_hoehe_1"] = foerderer.get("H1")
+ eintrag["kurvenrichtung"] = foerderer.get("kurvenrichtung")
+ voerder_anweisung = 1
+ elif voerder_anweisung ==1:
+ eintrag["vario_hoehe_0_1"] = foerderer.get("H0")
+ eintrag["vario_hoehe_1_1"] = foerderer.get("H1")
+ eintrag["kurvenrichtung_1"] = foerderer.get("kurvenrichtung")
+
for kreis in kreisel:
if kreis["Id"] in gerade["NachbarIds"]:
if anweisungen == 0:
@@ -3401,29 +3539,29 @@ def main(csv_path: Path, lib_path: Path, cfg_path: Path, allgemein_cfg_path: Pat
else:
print(msg)
continue
- data = []
- for e in msp.query("INSERT"):
- block_name = e.dxf.name
- block = doc.blocks[block_name]
+ # data = []
+ # for e in msp.query("INSERT"):
+ # block_name = e.dxf.name
+ # block = doc.blocks[block_name]
- # Bounding Box des Blocks berechnen
- bb = bbox.extents(block)
- if bb:
- x_min, y_min, z_min = bb.extmin
- x_max, y_max, z_max = bb.extmax
- width = (x_max - x_min) * e.dxf.xscale
- height_block = (y_max - y_min) * e.dxf.yscale
+ # # Bounding Box des Blocks berechnen
+ # bb = bbox.extents(block)
+ # if bb:
+ # x_min, y_min, z_min = bb.extmin
+ # x_max, y_max, z_max = bb.extmax
+ # width = (x_max - x_min) * e.dxf.xscale
+ # height_block = (y_max - y_min) * e.dxf.yscale
- x, y, hoehe = e.dxf.insert
- data.append({
- "blockname" : e.dxf.name,
- "x": x,
- "y": y,
- "höhe": hoehe,
- "rotation": e.dxf.rotation,
- "width": width,
- "height_block": height_block
- })
+ # x, y, hoehe = e.dxf.insert
+ # data.append({
+ # "blockname" : e.dxf.name,
+ # "x": x,
+ # "y": y,
+ # "höhe": hoehe,
+ # "rotation": e.dxf.rotation,
+ # "width": width,
+ # "height_block": height_block
+ # })
# for insert in msp.query("INSERT"):
# name = insert.dxf.name # Name des referenzierten Blocks
@@ -3440,8 +3578,8 @@ def main(csv_path: Path, lib_path: Path, cfg_path: Path, allgemein_cfg_path: Pat
# layer = insert.dxf.layer
# DXF speichern
- with open(output_path_jason, "w", encoding="utf-8") as datei:
- json.dump(data, datei, ensure_ascii=False, indent=4)
+ # with open(output_path_jason, "w", encoding="utf-8") as datei:
+ # json.dump(data, datei, ensure_ascii=False, indent=4)
doc.saveas(output_path)
if logger:
logger.info(f"[DONE] DXF gespeichert unter: {output_path}")
diff --git a/lib/test_files.py b/lib/test_files.py
index 6e88200..4ce603a 100644
--- a/lib/test_files.py
+++ b/lib/test_files.py
@@ -46,99 +46,110 @@ class TestDXFGeometry(unittest.TestCase):
omniflo_bogen = "omniflo_bogen"
omniflo_bogen_csv = self.testordner_path / f"{omniflo_bogen}.csv"
omniflo_bogen_dxf = f"{omniflo_bogen}.dxf"
+ omniflo_bogen_jason = self.work_dir / f"{omniflo_bogen}.jason"
omniflo_bogen_output = self.work_dir / omniflo_bogen_dxf
omniflo_bogen_reference = self.testordner_path / omniflo_bogen_dxf
- plant2dxf.main(omniflo_bogen_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, omniflo_bogen_output)
+ plant2dxf.main(omniflo_bogen_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, omniflo_bogen_output,omniflo_bogen_jason)
self.assert_dxf_geometry_equal(omniflo_bogen_output, omniflo_bogen_reference)
def test_weiche_90_dxf_file(self):
weiche_90= "weiche_90"
weiche_90_csv = self.testordner_path / f"{weiche_90}.csv"
weiche_90_dxf = f"{weiche_90}.dxf"
+ weiche_90_jason = self.work_dir /f"{weiche_90}.jason"
weiche_90_output = self.work_dir / weiche_90_dxf
weiche_90_reference = self.testordner_path / weiche_90_dxf
- plant2dxf.main(weiche_90_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weiche_90_output)
+ plant2dxf.main(weiche_90_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weiche_90_output,weiche_90_jason)
self.assert_dxf_geometry_equal(weiche_90_output, weiche_90_reference)
def test_weiche_45_simple_dxf_file(self):
weiche_45_simple= "weiche_45_simple"
weiche_45_simple_csv = self.testordner_path / f"{weiche_45_simple}.csv"
weiche_45_simple_dxf = f"{weiche_45_simple}.dxf"
+ weiche_45_simple_jason = self.work_dir/ f"{weiche_45_simple}.jason"
weiche_45_simple_output = self.work_dir / weiche_45_simple_dxf
weiche_45_simple_reference = self.testordner_path / weiche_45_simple_dxf
- plant2dxf.main(weiche_45_simple_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weiche_45_simple_output)
+ plant2dxf.main(weiche_45_simple_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weiche_45_simple_output,weiche_45_simple_jason)
self.assert_dxf_geometry_equal(weiche_45_simple_output, weiche_45_simple_reference)
def test_weiche_45_doppel_dxf_file(self):
weiche_45_doppel= "weiche_45_doppel"
weiche_45_doppel_csv = self.testordner_path / f"{weiche_45_doppel}.csv"
weiche_45_doppel_dxf = f"{weiche_45_doppel}.dxf"
+ weiche_45_doppel_jason = self.work_dir /f"{weiche_45_doppel}.jason"
weiche_45_doppel_output = self.work_dir / weiche_45_doppel_dxf
weiche_45_doppel_reference = self.testordner_path / weiche_45_doppel_dxf
- plant2dxf.main(weiche_45_doppel_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weiche_45_doppel_output)
+ plant2dxf.main(weiche_45_doppel_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weiche_45_doppel_output,weiche_45_doppel_jason)
self.assert_dxf_geometry_equal(weiche_45_doppel_output, weiche_45_doppel_reference)
def test_weiche_45_dreiwege_dxf_file(self):
weiche_45_dreiwege= "weiche_45_dreiwege"
weiche_45_dreiwege_csv = self.testordner_path / f"{weiche_45_dreiwege}.csv"
weiche_45_dreiwege_dxf = f"{weiche_45_dreiwege}.dxf"
+ weiche_45_dreiwege_jason = self.work_dir /f"{weiche_45_dreiwege}.jason"
weiche_45_dreiwege_output = self.work_dir / weiche_45_dreiwege_dxf
weiche_45_dreiwege_reference = self.testordner_path / weiche_45_dreiwege_dxf
- plant2dxf.main(weiche_45_dreiwege_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weiche_45_dreiwege_output)
+ plant2dxf.main(weiche_45_dreiwege_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weiche_45_dreiwege_output,weiche_45_dreiwege_jason)
self.assert_dxf_geometry_equal(weiche_45_dreiwege_output, weiche_45_dreiwege_reference)
def test_weichenkoerper_dxf_file(self):
weichenkoerper= "weichenkoerper"
weichenkoerper_csv = self.testordner_path / f"{weichenkoerper}.csv"
weichenkoerper_dxf = f"{weichenkoerper}.dxf"
+ weichenkoerper_jason = self.work_dir /f"{weichenkoerper}.jason"
weichenkoerper_output = self.work_dir / weichenkoerper_dxf
weichenkoerper_reference = self.testordner_path / weichenkoerper_dxf
- plant2dxf.main(weichenkoerper_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weichenkoerper_output)
+ plant2dxf.main(weichenkoerper_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weichenkoerper_output,weichenkoerper_jason)
self.assert_dxf_geometry_equal(weichenkoerper_output, weichenkoerper_reference)
def test_weichenkombination_dxf_file(self):
weichenkombination= "weichenkombination"
weichenkombination_csv = self.testordner_path / f"{weichenkombination}.csv"
weichenkombination_dxf = f"{weichenkombination}.dxf"
+ weichenkombination_jason = self.work_dir /f"{weichenkombination}.jason"
weichenkombination_output = self.work_dir / weichenkombination_dxf
weichenkombination_reference = self.testordner_path / weichenkombination_dxf
- plant2dxf.main(weichenkombination_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weichenkombination_output)
+ plant2dxf.main(weichenkombination_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weichenkombination_output,weichenkombination_jason)
self.assert_dxf_geometry_equal(weichenkombination_output, weichenkombination_reference)
def test_gefaelle_dxf_file(self):
gefaelle= "gefaelle"
gefaelle_csv = self.testordner_path / f"{gefaelle}.csv"
gefaelle_dxf = f"{gefaelle}.dxf"
+ gefaelle_jason = self.work_dir /f"{gefaelle}.jason"
weichenkombination_output = self.work_dir / gefaelle_dxf
weichenkombination_reference = self.testordner_path / gefaelle_dxf
- plant2dxf.main(gefaelle_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weichenkombination_output)
+ plant2dxf.main(gefaelle_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, weichenkombination_output,gefaelle_jason)
self.assert_dxf_geometry_equal(weichenkombination_output, weichenkombination_reference)
def test_gefaelle_ausnahme_gleiche_orientierung_dxf_file(self):
gefaelle_ausnahme_gleiche_orientierung= "gefaelle_ausnahme_gleiche_orientierung"
gefaelle_ausnahme_gleiche_orientierung_csv = self.testordner_path / f"{gefaelle_ausnahme_gleiche_orientierung}.csv"
gefaelle_ausnahme_gleiche_orientierung_dxf = f"{gefaelle_ausnahme_gleiche_orientierung}.dxf"
+ gefaelle_ausnahme_gleiche_orientierung_jason = self.work_dir /f"{gefaelle_ausnahme_gleiche_orientierung}.jason"
gefaelle_ausnahme_gleiche_orientierung_output = self.work_dir / gefaelle_ausnahme_gleiche_orientierung_dxf
gefaelle_ausnahme_gleiche_orientierung_reference = self.testordner_path / gefaelle_ausnahme_gleiche_orientierung_dxf
- plant2dxf.main(gefaelle_ausnahme_gleiche_orientierung_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, gefaelle_ausnahme_gleiche_orientierung_output)
+ plant2dxf.main(gefaelle_ausnahme_gleiche_orientierung_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, gefaelle_ausnahme_gleiche_orientierung_output,gefaelle_ausnahme_gleiche_orientierung_jason)
self.assert_dxf_geometry_equal(gefaelle_ausnahme_gleiche_orientierung_output, gefaelle_ausnahme_gleiche_orientierung_reference)
def test_gefaelle_ausnahme_unterschiedlich_orientierung_dxf_file(self):
gefaelle_ausnahme_unterschiedlich_orientierung= "gefaelle_ausnahme_unterschiedlich_orientierung"
gefaelle_ausnahme_unterschiedlich_orientierung_csv = self.testordner_path / f"{gefaelle_ausnahme_unterschiedlich_orientierung}.csv"
gefaelle_ausnahme_unterschiedlich_orientierung_dxf = f"{gefaelle_ausnahme_unterschiedlich_orientierung}.dxf"
+ gefaelle_ausnahme_unterschiedlich_orientierung_jason = self.work_dir /f"{gefaelle_ausnahme_unterschiedlich_orientierung}.jason"
gefaelle_ausnahme_unterschiedlich_orientierung_output = self.work_dir / gefaelle_ausnahme_unterschiedlich_orientierung_dxf
gefaelle_ausnahme_unterschiedlich_orientierung_reference = self.testordner_path / gefaelle_ausnahme_unterschiedlich_orientierung_dxf
- plant2dxf.main(gefaelle_ausnahme_unterschiedlich_orientierung_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, gefaelle_ausnahme_unterschiedlich_orientierung_output)
+ plant2dxf.main(gefaelle_ausnahme_unterschiedlich_orientierung_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, gefaelle_ausnahme_unterschiedlich_orientierung_output,gefaelle_ausnahme_unterschiedlich_orientierung_jason)
self.assert_dxf_geometry_equal(gefaelle_ausnahme_unterschiedlich_orientierung_output, gefaelle_ausnahme_unterschiedlich_orientierung_reference)
def test_gefaelle_einzeln_verbunden_dxf_file(self):
gefaelle_einzeln_verbunden= "gefaelle_einzeln_verbunden"
gefaelle_einzeln_verbunden_csv = self.testordner_path / f"{gefaelle_einzeln_verbunden}.csv"
gefaelle_einzeln_verbunden_dxf = f"{gefaelle_einzeln_verbunden}.dxf"
+ gefaelle_einzeln_verbunden_jason = self.work_dir /f"{gefaelle_einzeln_verbunden}.jason"
gefaelle_einzeln_verbunden_output = self.work_dir / gefaelle_einzeln_verbunden_dxf
gefaelle_einzeln_verbunden_reference = self.testordner_path / gefaelle_einzeln_verbunden_dxf
- plant2dxf.main(gefaelle_einzeln_verbunden_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, gefaelle_einzeln_verbunden_output)
+ plant2dxf.main(gefaelle_einzeln_verbunden_csv , self.default_lib_path, self.cfg_path, self.allgemein_cfg_path, gefaelle_einzeln_verbunden_output,gefaelle_einzeln_verbunden_jason)
self.assert_dxf_geometry_equal(gefaelle_einzeln_verbunden_output, gefaelle_einzeln_verbunden_reference)