Die tags sind nun unsichtbar und nur ein Name wird erstellt. Die z Kordinatenfür ILS syteme wurden hinzugefügt und eine vorübergehende arc für angetriebene Kurven wird erstllet bevor man die Inserts hat

This commit is contained in:
2025-09-17 11:37:31 +02:00
parent 291b2eaec5
commit aa04ee3fd1
2 changed files with 52 additions and 27 deletions
+2 -6
View File
@@ -117,14 +117,10 @@ def create_block_library(input_dir, output_file, config, logger=None):
cp = copy_entity(logger, error_files, filename, e, center)
if cp:
blk.add_entity(cp)
add_bounding_box_to_modelspace(blk, boundingbox, centered=True)
# add_bounding_box_to_modelspace(blk, boundingbox, centered=True)
# Platzierung in Reihen und Spalten
# Attribut-Definition (ATTDEF) hinzufügen
blk.add_attdef(
tag="NAME",
insert=(0.2, 0.2), # Position relativ zum Blockursprung
)
# Blockreferenz-Layer bestimmen
blockref_layer = None
+50 -21
View File
@@ -155,7 +155,7 @@ def berechne_hoehe(csv_path, logger=None):
def transform_coords(x: float, y: float, height: float) -> tuple[float, float]:
"""Transformiert Bildschirmkoordinaten (0,0 oben links) ins DXF-KoSy (0,0 unten links)."""
return x, height - y
return x, y
def handle_ils_2_0_kreisel(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols):
abstand_m = merkmale.get(
@@ -168,7 +168,7 @@ def handle_ils_2_0_kreisel(msp, teileid, merkmale, x, y, doc, lib_doc, verbose,
# Drehung (Winkel in Grad, Standard 0) aus Merkmale
try:
winkel = float(merkmale.get("Drehung", 0))
winkel = float(merkmale.get("Drehung", 90))
except (ValueError, TypeError):
winkel = 0.0
winkel_rad = math.radians(winkel)
@@ -177,8 +177,8 @@ def handle_ils_2_0_kreisel(msp, teileid, merkmale, x, y, doc, lib_doc, verbose,
halbabstand = abstand / 2
dx = halbabstand * math.cos(winkel_rad)
dy = halbabstand * math.sin(winkel_rad)
pos1 = (x - dx, y - dy)
pos2 = (x + dx, y + dy)
pos1 = (x - dx, y - dy,float(merkmale.get("Höhe in m"))* 1000)
pos2 = (x + dx, y + dy, float(merkmale.get("Höhe in m"))* 1000)
positions = [pos1, pos2]
for i, sym in enumerate(symbols):
blockname = sym["name"]
@@ -199,8 +199,8 @@ def handle_ils_2_0_kreisel(msp, teileid, merkmale, x, y, doc, lib_doc, verbose,
def draw_kreisel_lines(msp, pos1, pos2):
"""Zeichnet tangentiale Linien zwischen zwei Kreiselblöcken, unabhängig vom Winkel."""
x1, y1 = pos1
x2, y2 = pos2
x1, y1, z1 = pos1
x2, y2, z1 = pos2
# Verbindungsvektor
dx = x2 - x1
dy = y2 - y1
@@ -212,10 +212,10 @@ def draw_kreisel_lines(msp, pos1, pos2):
nx = -dy / length * RADIUS
ny = dx / length * RADIUS
# Tangentialpunkte
p1a = (x1 + nx, y1 + ny)
p1b = (x1 - nx, y1 - ny)
p2a = (x2 + nx, y2 + ny)
p2b = (x2 - nx, y2 - ny)
p1a = (x1 + nx, y1 + ny,z1)
p1b = (x1 - nx, y1 - ny,z1)
p2a = (x2 + nx, y2 + ny,z1)
p2b = (x2 - nx, y2 - ny,z1)
# Linien zeichnen
msp.add_line(p1a, p2a)
msp.add_line(p1b, p2b)
@@ -224,8 +224,8 @@ def draw_kreisel_drehrichtung_markierung(msp, pos1, pos2, merkmale, lib_doc, doc
drehrichtung = merkmale.get("Drehrichtung", "").upper()
if drehrichtung not in ("UZS", "GUZS"):
return
x1, y1 = pos1
x2, y2 = pos2
x1, y1,z1= pos1
x2, y2,z2 = pos2
dx = x2 - x1
dy = y2 - y1
length = math.hypot(dx, dy)
@@ -250,7 +250,7 @@ def draw_kreisel_drehrichtung_markierung(msp, pos1, pos2, merkmale, lib_doc, doc
rotation += 180
import_block("S-LP", lib_doc, doc)
blockref_layer = get_layer(doc, lib_doc, "S-LP")
bref = msp.add_blockref("S-LP", (px, py), dxfattribs={"rotation": rotation,"layer": blockref_layer})
bref = msp.add_blockref("S-LP", (px, py,z1), dxfattribs={"rotation": rotation,"layer": blockref_layer})
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)
@@ -263,7 +263,7 @@ def draw_kreisel_drehrichtung_markierung(msp, pos1, pos2, merkmale, lib_doc, doc
rotation += 180
import_block("S-LP", lib_doc, doc)
blockref_layer = get_layer(doc, lib_doc, "S-LP")
bref = msp.add_blockref("S-LP", (px, py), dxfattribs={"rotation": rotation , "layer": blockref_layer})
bref = msp.add_blockref("S-LP", (px, py, z1), dxfattribs={"rotation": rotation , "layer": blockref_layer})
if verbose:
print(f"[INFO] Drehrichtung '{drehrichtung}': S-LP unten bei ({px:.1f}, {py:.1f}), rot={rotation:.1f}")
@@ -296,10 +296,10 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
# Die Koordinaten (x, y) sind die Mitte der Strecke
halbe_laenge = laenge / 2
dx = halbe_laenge * math.cos(winkel_rad)
dy = halbe_laenge * math.sin(winkel_rad)
start = (x - dx, y - dy)
ende = (x + dx, y + dy)
dx = halbe_laenge * math.sin(winkel_rad)
dy = halbe_laenge * math.cos(winkel_rad)
start = (x + dx, y + dy,float(merkmale.get("Höhe oben") ) *1000)
ende = (x - dx, y - dy,float(merkmale.get("Höhe unten")) * 1000)
msp.add_line(start, ende)
if verbose:
print(f"[INFO] Gefällestrecke → {teileid} Linie von ({start[0]:.1f}, {start[1]:.1f}) nach ({ende[0]:.1f}, {ende[1]:.1f})")
@@ -323,6 +323,31 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
elif lib_doc is None:
print("[WARN] lib_doc nicht verfügbar, Blöcke werden nicht eingefügt.")
def handle_ils_2_0_kurve_angetrieben(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols):
center =x,y
winkel_deg = float(merkmale.get("Kurvenwinkel"))
richtung = merkmale.get("Kurvenrichtung")
if richtung.lower() == "links":
end_angle = 180
else:
start_angle= 0
# Endwinkel je nach Richtung
if richtung.lower() == "links":
start_angle = end_angle- winkel_deg
elif richtung.lower() == "rechts":
end_angle = start_angle + winkel_deg
else:
raise ValueError("Unbekannte Kurvenrichtung: Muss 'links' oder 'rechts' sein")
msp.add_arc(
center=center,
radius=400,
start_angle=start_angle,
end_angle=end_angle
)
def handle_omniflo(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols):
"""
Für Omniflo Gerade: zeichnet eine Linie (Mitte = Koordinate, Länge und Winkel aus Merkmale).
@@ -344,8 +369,8 @@ def handle_omniflo(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols)
dx = halbe_laenge * math.sin(winkel_rad)
dy = halbe_laenge * math.cos(winkel_rad)
start = (x + dx, y + dy, float(merkmale.get("Höhe oben"))*1000 )
ende = (x - dx, y - dy, float(merkmale.get("Höhe unten"))*1000 )
start = (x + dx, y + dy, float(merkmale.get("Höhe oben")) )
ende = (x - dx, y - dy, float(merkmale.get("Höhe unten")))
msp.add_line(start, ende)
if verbose:
@@ -368,17 +393,21 @@ def handle_omniflo(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols)
bref = msp.add_blockref(blockname, (x, y,float(merkmale.get("Höhe"))), dxfattribs={"xscale": 1.0, "yscale":1.0,"rotation": drehung, "layer": blockref_layer})
bref.add_attrib(
a =bref.add_attrib(
tag= "NAME",
text= merkmale.get("bezeichner"),
insert = (x,y)
)
a.is_invisible = True
bref.add_auto_attribs({ATTR_TAG: teileid})
if verbose:
print(f"[INFO] Block '{blockname}' (Omniflo) → {teileid} ({x:.1f}, {y:.1f})")
def get_layer(doc, lib_doc, blockname):
src = lib_doc.blocks[blockname]
try: