Files
plant2dxf/lib/plant2dxf.py
T

3112 lines
178 KiB
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
placeblocks.py
Erzeugt DXF-Elemente aus einer RuleDesigner-CSV.
"""
import os
import sys
import csv
import json
import re
import argparse
import configparser
import ezdxf
from ezdxf import units
from ezdxf.entities import Line
from ezdxf.addons import importer
from ezdxf.math import Matrix44, X_AXIS,Y_AXIS,Z_AXIS
from ezdxf import bbox
from pathlib import Path
import math
import re
from utils import check_environment_var, setup_logger
# global_zaehler = 0
# --------------------------------------------------------- CFG-Leser für shapes.cfg
def get_shape_cfg(teileart, cfg_path, logger=None):
parser = configparser.ConfigParser()
try:
with open(cfg_path, encoding='utf-8') as f:
parser.read_file(f)
except Exception as e:
msg = f"Fehler beim Lesen der Config-Datei {cfg_path}: {e}"
if logger:
logger.error(msg)
else:
print(msg)
return []
section = teileart
if section not in parser:
return []
# Blöcke
items = parser.get(section, "items", fallback="").replace('"', '').split(",")
blocks = [item.strip() for item in items if item.strip()]
symbols = []
for i, name in enumerate(blocks):
# Offset
offset_key = f"offset_symb{i+1}"
offset_str = parser.get(section, offset_key, fallback="0,0")
try:
ox, oy = [float(x) for x in offset_str.split(",")]
except Exception:
ox, oy = 0.0, 0.0
# Rotation
rot_key = f"rot_symb{i+1}"
rot_str = parser.get(section, rot_key, fallback="0.0")
try:
rot = float(rot_str)
except Exception:
rot = 0.0
symbols.append({
"name": name,
"offset": (ox, oy),
"rotation": rot
})
return symbols
# --------------------------------------------------------- Konstante Parameter
ATTR_TAG = "TeileId" # Attributtag im Block
RADIUS = 400 # Radius der Kreiselkreise (mm)
# --------------------------------------------------------- Hilfsfunktionen
def extract_coords(planquadrat: str) -> tuple[float, float]:
"""Extrahiert X/Y Koordinaten aus PlanquadratString."""
m = re.search(r"X:(\d+[\.,]?\d*)\s+Y:(\d+[\.,]?\d*)", planquadrat)
if not m:
raise ValueError(f"Koordinaten nicht gefunden in: '{planquadrat}'")
x, y = m.groups()
return float(x.replace(",", ".")), float(y.replace(",", "."))
def parse_merkmale(merkmale_str: str) -> dict:
"""Parst Merkmale-JSON-String in dict; bei Fehler → leeres Dict."""
try:
return json.loads(merkmale_str)
except json.JSONDecodeError:
return {}
def import_block(block_name: str, from_doc, to_doc, winkel = None) -> None:
"""Importiert Blockdefinition block_name von from_doc nach to_doc.
- Kopiert alle Entities des Blocks
- Stellt sicher, dass benutzte Layer im Ziel existieren (mit Eigenschaften)
- Übernimmt Basis­punkt und Block-Layer, falls vorhanden
"""
src = from_doc.blocks[block_name]
att_def = {}
if block_name == "Pinbereich":
imp = importer.Importer(from_doc, to_doc)
# Alle Linientypen importieren
imp.import_table("linetypes")
if ((block_name in to_doc.blocks)):
# speichern der attdef elemente in eine Liste falks diese verhanden sind und gibt diese zurück
for ent in src:
copy = ent.copy()
if ent.dxftype() == "ATTDEF":
att_def[ent.dxf.tag] =ent.dxf.text
if ent.dxftype() == "INSERT":
import_block(ent.dxf.name,from_doc, to_doc,None)
if att_def != {}:
return att_def
return
if block_name not in from_doc.blocks:
raise ValueError(f"Block '{block_name}' nicht in Bibliothek gefunden.")
# Sicherstellen, dass alle verwendeten Layer existieren
try:
used_layer_names = {e.dxf.layer for e in src if hasattr(e.dxf, "layer")}
for layer_name in used_layer_names:
if layer_name and layer_name not in to_doc.layers:
try:
src_layer = from_doc.layers.get(layer_name)
to_doc.layers.add(
name=layer_name,
color=getattr(src_layer.dxf, "color", None),
linetype=getattr(src_layer.dxf, "linetype", None),
lineweight=getattr(src_layer.dxf, "lineweight", None),
)
except Exception:
# Fallback: Layer mit Standardwerten anlegen
to_doc.layers.add(name=layer_name)
except Exception:
pass
tgt = to_doc.blocks.new(name=block_name)
# Basis­punkt/Layer des Blocks übernehmen, wenn vorhanden
try:
tgt.block.dxf.base_point = src.block.dxf.base_point
except Exception:
pass
try:
tgt.block.dxf.layer = src.block.dxf.layer
except Exception:
pass
# kopiert die elemente von dem element aus dem block und speichert diese in den block für dass Modelspace auf und # speichern der attdef elemente in eine Liste falks diese verhanden sind und gibt diese zurück
for ent in src:
copy = ent.copy()
if ent.dxftype() == "ATTDEF":
att_def[ent.dxf.tag] =ent.dxf.text
if ent.dxftype() == "INSERT":
import_block(ent.dxf.name,from_doc, to_doc,None)
tgt.add_entity(copy)
if att_def != {}:
return att_def
def dreh_block(block_name: str, to_doc, winkel) :
"""Nimmt ein schon importierten Block und erstellt einen neuen der an der y_axis gedreht wird
hauptsächlich für vario Bogen aktuell verwendet
"""
dreh_block_name = block_name +f"_{math.degrees(winkel)}"
if (dreh_block_name in to_doc.blocks):
return dreh_block_name
block_zwischen = to_doc.blocks.new(name=block_name + f"zwischenschrit_{winkel}", base_point=(0,0,0))
block = to_doc.blocks.new(name=dreh_block_name, base_point=(0,0,0))
rotation_matrix = Matrix44.axis_rotate(Y_AXIS, winkel)
block_zwischen.add_blockref(block_name,(0,0,0))
for e in block_zwischen:
copy = e.copy()
copy.transform(rotation_matrix)
block.add_entity(copy)
return dreh_block_name
def berechne_hoehe(csv_path, logger=None):
y_werte = []
try:
with csv_path.open(newline="", encoding="utf-8") as fh:
reader = csv.DictReader(fh, delimiter=';')
for row in reader:
planquadrat = row.get("Planquadrat", "")
try:
_, y = extract_coords(planquadrat)
y_werte.append(y)
except Exception as e:
if logger:
logger.warning(f"Fehler beim Extrahieren der Koordinate aus '{planquadrat}': {e}")
except Exception as e:
if logger:
logger.error(f"Fehler beim Lesen der CSV-Datei {csv_path}: {e}")
else:
print(f"Fehler beim Lesen der CSV-Datei {csv_path}: {e}")
return 0
if not y_werte:
msg = "Keine Y-Koordinaten in der CSV gefunden!"
if logger:
logger.error(msg)
else:
print(msg)
raise ValueError(msg)
return max(y_werte)
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, y
def handle_ils_2_0_kreisel_mit_pin(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols,strecken_nachbarn,config,config_allgemein):
handle_ils_2_0_kreisel(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols,strecken_nachbarn,config,config_allgemein)
def handle_ils_2_0_kreisel(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols,strecken_nachbarn,config,config_allgemein):
scanner = float(merkmale.get("Anzahl der Scanner"))
separatoren = float(merkmale.get("Anzahl der Separatoren"))
block_scanner = "SCAN"
block_separatoren = "S-LP"
scanner_x = x
scanner_y = y
separatoren_x = x
separatoren_y = y + 160
import_block(block_scanner,lib_doc,doc)
import_block(block_separatoren,lib_doc,doc)
i = 0
while i < scanner:
msp.add_blockref(block_scanner, (scanner_x,scanner_y,float(merkmale.get("Höhe in m"))* 1000))
scanner_x = scanner_x + 300
i = i+1
i = 0
while i < separatoren:
msp.add_blockref(block_separatoren, (separatoren_x,separatoren_y,float(merkmale.get("Höhe in m"))* 1000))
separatoren_x = separatoren_x + 300
i = i +1
abstand_m = merkmale.get(
"Abstand (Kreiselachse A - Kreiselachse) in Meter", "20"
).replace(",", ".")
try:
abstand = float(abstand_m) * 1000 # Meter → mm
except ValueError:
abstand = 10000 # Fallback 10m
# Drehung (Winkel in Grad, Standard 0) aus Merkmale
try:
winkel = float(merkmale.get("Drehung"))
except (ValueError, TypeError):
winkel = 0.0
if winkel== 270 or winkel == 90:
winkel_rad = math.radians(winkel)
else:
winkel_rad = math.radians(winkel -180)
# Die Koordinaten (x, y) sind die Mitte zwischen den beiden Blöcken (bereits transformiert)
halbabstand = abstand / 2
dx = halbabstand * math.cos(winkel_rad)
dy = halbabstand * math.sin(winkel_rad)
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"]
offset = sym["offset"]
rotation = sym["rotation"]
if i < len(positions):
pos = (positions[i][0] + offset[0], positions[i][1] + offset[1],float(merkmale.get("Höhe in m"))*1000)
import_block(blockname, lib_doc, doc)
blockref_layer = get_layer(doc, lib_doc, blockname)
bref = msp.add_blockref(blockname, pos, dxfattribs={"layer" : blockref_layer})
bref.add_auto_attribs({ATTR_TAG: teileid})
if verbose:
print(f"[INFO] Block '{blockname}' (Kreisel) → {teileid} "
f"({pos[0]:.1f}, {pos[1]:.1f}), rot={rotation}")
# Linien zeichnen
import_block("Pinbereich",lib_doc,doc)
draw_kreisel_lines(msp, pos1, pos2,merkmale)
draw_kreisel_drehrichtung_markierung(msp, pos1, pos2, merkmale, lib_doc, doc, verbose)
def draw_kreisel_lines(msp, pos1, pos2,merkmale):
"""Zeichnet tangentiale Linien zwischen zwei Kreiselblöcken, unabhängig vom Winkel."""
x1, y1, z1 = pos1
x2, y2, z1 = pos2
# Verbindungsvektor
dx = x2 - x1
dy = y2 - y1
# Länge
length = math.hypot(dx, dy)
if length == 0:
return # keine Linie bei identischen Punkten
# Normalenvektor (senkrecht, normiert, Länge = RADIUS)
nx = -dy / length * RADIUS
ny = dx / length * RADIUS
# Tangentialpunkte
p1a = (x1 + nx, y1 + ny,z1)
p1b = (x1 - nx, y1 - ny,z1)
p2a = (x2 + nx, y2 + ny,z1)
p2b = (x2 - nx, y2 - ny,z1)
if merkmale.get("Kreiselart") == "Pin":
p1a2 = p1a[0] + RADIUS + 50, p1a[1] - 50, z1
p1b2 = p1b[0] + RADIUS + 50, p1b[1] + 50, z1
p2a2 = p2a[0] - RADIUS - 50, p2a[1] - 50, z1
p2b2 = p2b[0] - RADIUS - 50, p2b[1] + 50, z1
Line1 = Line.new(dxfattribs={"start": p1a2,"end": p2a2,"layer": "Pinbereich"})
Line2 = Line.new(dxfattribs={"start": p1b2,"end": p2b2,"layer": "Pinbereich"})
msp.add_entity(Line1)
msp.add_entity(Line2)
# Linien zeichnen
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,z1= pos1
x2, y2,z2 = 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("Richtungspfeil", lib_doc, doc)
blockref_layer = get_layer(doc, lib_doc, "Richtungspfeil")
bref = msp.add_blockref("Richtungspfeil", (px, py,z1), dxfattribs={"rotation": rotation,"layer": blockref_layer})
if verbose:
print(f"[INFO] Drehrichtung '{drehrichtung}': Richtungspfeil 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("Richtungspfeil", lib_doc, doc)
blockref_layer = get_layer(doc, lib_doc, "Richtungspfeil")
bref = msp.add_blockref("Richtungspfeil", (px, py, z1), dxfattribs={"rotation": rotation , "layer": blockref_layer})
if verbose:
print(f"[INFO] Drehrichtung '{drehrichtung}':Richtungspfeil 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)
blockref_layer = get_layer(doc, lib_doc, blockname)
bref = msp.add_blockref(blockname, (x, y), dxfattribs={"layer": blockref_layer})
bref.add_auto_attribs({ATTR_TAG: teileid})
if verbose:
print(f"[INFO] Block '{blockname}' (Standard) → {teileid} "
f"({x:.1f}, {y:.1f})")
def handle_ils_2_0_eckrad(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
import_block("AN8",lib_doc,doc)
import_block("Richtungspfeil",lib_doc,doc)
eckrad_rechts = "eckrad_UZS"
eckrad_links = "eckrad_GUZS"
hight = float(merkmale.get("Höhe in m"))
if eckrad_rechts not in doc.blocks:
block_rechts = doc.blocks.new(name= eckrad_rechts,base_point=(0,0,0))
block_links = doc.blocks.new(name= eckrad_links,base_point=(0,0,0))
block_rechts.add_blockref("AN8",(0,0,0))
block_links.add_blockref("AN8",(0,0,0))
block_rechts.add_blockref("Richtungspfeil",(0+200,0+ RADIUS,0))
block_rechts.add_blockref("Richtungspfeil",(0-200,0- RADIUS,0),dxfattribs={"rotation": 180})
block_links.add_blockref("Richtungspfeil",(0+200,0- RADIUS,0))
block_links.add_blockref("Richtungspfeil",(0-200,0+ RADIUS,0),dxfattribs={"rotation": 180})
if merkmale.get("Drehrichtung") == "UZS":
msp.add_blockref(eckrad_rechts,(x,y,hight))
elif merkmale.get("Drehrichtung") == "GUZS":
msp.add_blockref(eckrad_links,(x,y,hight))
else:
msp.add("AN8",x,y,hight)
def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
#Vorbereitung der attributen
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
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
halbe_laenge = laenge / 2
rotation= float(merkmale.get("Drehung"))
if "6-SP" not in doc.layers:
doc.layers.add(name="6-SP", color=7)
verbunden_am_einen = False
tefkurve_0 = None
tefkurve_1 = None
hat_motor_0 = False
hat_umlenk_0 =False
hat_motor_1 = False
hat_umlenk_1 =False
richtung2 ="DEFAULT"
unterschiedlich = False
winkel = math.radians(float(rotation))
dx = halbe_laenge *math.sin(winkel * -1)
dy = halbe_laenge * math.cos(winkel)
start = x +dx, y + dy,upper_hoehe_gefaehlle
separatoren =float(merkmale.get("Anzahl der Separatoren"))
scanner = float(merkmale.get("Anzahl der Scanner"))
if rotation == 0 or rotation == -180:
ausrichtung = "V"
else:
ausrichtung = "H"
if ausrichtung == "V":
einsatz_fest = [x + 300, y,hoehe_gefaehlle]
modular = 2
else:
einsatz_fest = [x,y - 150,hoehe_gefaehlle]
modular = 3
block_scanner = "SCAN"
block_separatoren = "S-LP"
import_block(block_scanner,lib_doc,doc)
import_block(block_separatoren,lib_doc,doc)
einsatz_zwischen =[ einsatz_fest[0],einsatz_fest[1],einsatz_fest[2]]
anzahl =0
while anzahl < separatoren:
anzahl = anzahl + 1
msp.add_blockref(block_separatoren,einsatz_zwischen)
if anzahl % modular == 0:
einsatz_fest[1] = einsatz_fest[1] - 150
einsatz_zwischen = einsatz_fest.copy()
else:
einsatz_zwischen[0] = einsatz_zwischen[0]+ 300
if anzahl % modular != 0:
einsatz_fest[1] = einsatz_fest[1] - 150
einsatz_zwischen = einsatz_fest.copy()
anzahl =0
while anzahl < scanner:
anzahl = anzahl + 1
msp.add_blockref(block_scanner,einsatz_zwischen)
if anzahl % modular == 0:
einsatz_fest[1] = einsatz_fest[1] - 150
einsatz_zwischen = einsatz_fest.copy()
else:
einsatz_zwischen[0] = einsatz_zwischen[0]+ 300
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"))
hoehe0 = float(gefaellestrecke_nachbarn.get("Hoehe0"))
richtung0 = float(gefaellestrecke_nachbarn.get("rotation0"))
richtung_rad0= math.radians(richtung0)
abstand0 = float(gefaellestrecke_nachbarn.get("abstand0")) * 1000
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
kurvenrichtung = gefaellestrecke_nachbarn.get("Kurvenrichtung")
tefkurve_0 = gefaellestrecke_nachbarn.get("Tefkurve")
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))
blockname_motor_links = block_Vario_Motorstation_500mm +"links"
blockname_umlenk_links = block_Vario_Umlenkstation_500mm + "links"
if blockname_motor_links not in doc.blocks:
matrix = Matrix44(1,-1,1)
block_motor_links = doc.blocks.new(name=blockname_motor_links,base_point=(0,0,0))
block_umlenk_links = doc.blocks.new(name=blockname_umlenk_links,base_point=(0,0,0))
block_motor_rechts = doc.blocks[block_Vario_Motorstation_500mm]
block_umlenk_rechts = doc.blocks[block_Vario_Umlenkstation_500mm]
for e in block_motor_rechts:
copy = e.copy()
copy.transform(matrix)
block_motor_links.add_entity(copy)
for e in block_umlenk_rechts:
copy = e.copy()
copy.transform(matrix)
block_umlenk_links.add_entity(copy)
if upper_hoehe_gefaehlle > lower_hoehe_gefaehlle:
if vario_hoehe_0 == upper_hoehe_gefaehlle or vario_hoehe_1 == upper_hoehe_gefaehlle:
hat_motor_0 = True
else:
hat_umlenk_0 = True
if upper_hoehe_gefaehlle < lower_hoehe_gefaehlle:
if vario_hoehe_0 == lower_hoehe_gefaehlle or vario_hoehe_1 == lower_hoehe_gefaehlle:
hat_motor_0 = True
else:
hat_umlenk_0 = 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:
if hat_motor_0 == False and hat_umlenk_0 == 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
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_0}_{hat_motor_0}_{tefkurve_0}"
if blockname not in doc.blocks:
block = doc.blocks.new(name=blockname,base_point= (0,0,0))
if hat_motor_0 == True:
if tefkurve_0 == "rechts":
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})
else:
block.add_blockref(blockname_motor_links, (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_0 == True:
if tefkurve_0 == "rechts":
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})
else:
block.add_blockref(blockname_umlenk_links, (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"
if hat_motor_0 == False and hat_umlenk_0 == 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_0}_{hat_motor_0}_{tefkurve_0}"
if blockname in doc.blocks:
bref =msp.add_blockref(blockname,(x,y,hoehe_gefaehlle),dxfattribs={"rotation": rotation})
a =bref.add_attrib(
tag= "NAME",
text= merkmale.get("bezeichner"),
insert = (x,y)
)
a.is_invisible = True
return
if laenge > asoffset or laenge > esoffset:
block = doc.blocks.new(name=blockname,base_point= (0,0,0))
else:
block = None
dy = halbe_laenge * math.cos(0)
start = [x , y + dy ,upper_hoehe_gefaehlle]
ende = [x , y - dy ,lower_hoehe_gefaehlle]
if hat_motor_0 == True:
if tefkurve_0 == "rechts":
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})
else:
block.add_blockref(blockname_motor_links, (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_0 == True:
if tefkurve_0 == "rechts":
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})
else:
block.add_blockref(blockname_umlenk_links, (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, upper_hoehe_gefaehlle, lower_hoehe_gefaehlle, hoehe_gefaehlle, drehung0, laenge, blockname,config,hight,None,None,None,block,start,ende)
if only_es_or_as == False:
bref =msp.add_blockref(blockname,(x,y,hoehe_gefaehlle),dxfattribs={"rotation": rotation})
a =bref.add_attrib(
tag= "NAME",
text= merkmale.get("bezeichner"),
insert = (x,y)
)
a.is_invisible = True
elif "Drehung0" in gefaellestrecke_nachbarn and "Drehung1" in gefaellestrecke_nachbarn:
winkel = math.radians(float(merkmale.get("Drehung")))
halbe_laenge = laenge / 2
dx = halbe_laenge *math.sin(winkel * -1)
dy = halbe_laenge * math.cos(winkel)
drehung0 =gefaellestrecke_nachbarn.get("Drehung0")
drehung1 = gefaellestrecke_nachbarn.get("Drehung1")
hoehe0 = gefaellestrecke_nachbarn.get("Hoehe0")
hoehe1 = gefaellestrecke_nachbarn.get("Hoehe1")
x0_kreisel = float(gefaellestrecke_nachbarn.get("x0"))
y0_kreisel = float(gefaellestrecke_nachbarn.get("y0"))
x1_kreisel = float(gefaellestrecke_nachbarn.get("x1"))
y1_kreisel = float(gefaellestrecke_nachbarn.get("y1"))
richtung0 = float(gefaellestrecke_nachbarn.get("rotation0"))
richtung1 = float(gefaellestrecke_nachbarn.get("rotation1"))
richtung2 ="DEFAULT"
richtung_rad0= math.radians(richtung0)
richtung_rad1 = math.radians(richtung1)
abstand0 = float(gefaellestrecke_nachbarn.get("abstand0")) * 1000
abstand1 = float(gefaellestrecke_nachbarn.get("abstand1")) * 1000
rotation = float(merkmale.get("Drehung"))
#ausrechnung position kreisel
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, x1_kreisel, y1_kreisel, richtung_rad1, abstand1)
# falls gefälle strecke mit zwei kreiseln verbunden zeichne eine einfache linie (später braucht man hier auch eine logik sobald man die richtigen es und as elemente hat)
if kreisel_verbunden == 2:
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
#umbezeichnung von den geraden zu strings ob es Vertikal oder Horizontal ist
if richtung0 == 90.0 or richtung0 ==270:
richtung0= "Vertikal"
else:
richtung0 = "Horinzontal"
if richtung1 == 90.0 or richtung1 ==270:
richtung1= "Vertikal"
else:
richtung1 = "Horinzontal"
richtung2,unterschiedlich = am_kreisel_direct_verbunden(x, y, upper_hoehe_gefaehlle, lower_hoehe_gefaehlle, x0_kreisel, y0_kreisel, richtung_rad0, abstand0, dx, dy, x1_kreisel, y1_kreisel, richtung_rad1, abstand1,kreisel_verbunden, richtung0 , richtung1 , richtung2 )
#Berechnung des Gefälles
if hoehe0 > hoehe1:
hight_position = "higher"
else:
hight_position = "lower"
if richtung2 == "DEFAULT":
if richtung0 == "Vertikal":
if x0_kreisel < x1_kreisel:
position = hight_position + "_links"
else:
position = hight_position + "_rechts"
else:
if y0_kreisel > y1_kreisel:
position = hight_position + "_higher"
else:
position = hight_position + "_lower"
if richtung0 == "Vertikal":
if position == "lower_rechts" or position == "higher_links":
gefaelle = "links"
else:
gefaelle = "rechts"
elif richtung0 == "Horinzontal":
if position == "lower_lower" or position == "higher_higher":
gefaelle = "oben"
else:
gefaelle = "unten"
# vertausch der drehung und der höhe für die namens gebung des blockes
if (position == "higher_rechts" or position == "lower_rechts" or position=="higher_lower" or position== "lower_lower") and drehung0 != drehung1 and am_kreisel == 0:
drehung_2 = drehung0
drehung0 = drehung1
drehung1= drehung_2
if hight_position == "higher":
hight_position = "lower"
else:
hight_position = "higher"
# austausch der werte damit immer davon ausgehen dass der 1 kreisel in unserer Liste am Kreisel verbuden ist
if kreisel_verbunden == 1 and am_kreisel ==2:
am_kreisel == 1
drehung_2 = drehung0
drehung0 = drehung1
drehung1= drehung_2
if hight_position == "higher":
hight_position = "lower"
else:
hight_position = "higher"
else:
if richtung2 == "Vertikal":
if x0_kreisel < x1_kreisel:
position = hight_position + "_links"
else:
position = hight_position + "_rechts"
else:
if y0_kreisel > y1_kreisel:
position = hight_position + "_higher"
else:
position = hight_position + "_lower"
if richtung2 == "Vertikal":
if position == "lower_rechts" or position == "higher_links":
gefaelle = "links"
else:
gefaelle = "rechts"
elif richtung2 == "Horinzontal":
if position == "lower_lower" or position == "higher_higher":
gefaelle = "oben"
else:
gefaelle = "unten"
# austausch der werte damit immer davon ausgehen dass der 1 kreisel in unserer Liste am Kreisel verbuden ist
if am_kreisel == 2:
am_kreisel = 1
drehung_2 = drehung0
drehung0 = drehung1
drehung1= drehung_2
if hight_position == "higher":
hight_position = "lower"
else:
hight_position = "higher"
if gefaelle == "oben":
rotation = 0
elif gefaelle == "unten" :
rotation = 180
elif gefaelle == "links" :
rotation = 90
elif gefaelle == "rechts" :
rotation = 270
#geben der richtung2 eines wertes außer default wenn beide kreisel die gleiche richung haben
if (kreisel_verbunden == 1 and richtung2 =="DEFAULT"):
richtung2 = richtung0
if richtung2 == "DEFAULT":
blockname = f"Ils_2.0_Gefaellestrecke_{laenge}_{hoehe_gefaehlle}_{drehung0}_{drehung1}_{hight_position}_{verbunden_am_einen}"
else:
blockname = f"Ils_2.0_Gefaellestrecke_{laenge}_{hoehe_gefaehlle}_{drehung0}_{drehung1}_{hight_position}_{unterschiedlich}_{richtung2}_{verbunden_am_einen}"
gefaellegerade_erstellung(x, y, doc, lib_doc, upper_hoehe_gefaehlle, lower_hoehe_gefaehlle, hoehe_gefaehlle,richtung2,drehung0, drehung1, laenge, hight_position,blockname,config)
blockref_layer = get_layer(doc, lib_doc, blockname)
bref =msp.add_blockref(blockname,(x,y,hoehe_gefaehlle),dxfattribs={"rotation": rotation, "layer": blockref_layer })
a = bref.add_attrib(
tag= "NAME",
text= merkmale.get("bezeichner"),
insert = (x,y)
)
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
kurvenrichtung = gefaellestrecke_nachbarn.get("Kurvenrichtung")
tefkurve_0 = gefaellestrecke_nachbarn.get("Tefkurve")
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))
blockname_motor_links = block_Vario_Motorstation_500mm +"links"
blockname_umlenk_links = block_Vario_Umlenkstation_500mm + "links"
if blockname_motor_links not in doc.blocks:
matrix = Matrix44.scale(1,-1,1)
block_motor_links = doc.blocks.new(name=blockname_motor_links,base_point=(0,0,0))
block_umlenk_links = doc.blocks.new(name=blockname_umlenk_links,base_point=(0,0,0))
block_motor_rechts = doc.blocks[block_Vario_Motorstation_500mm]
block_umlenk_rechts = doc.blocks[block_Vario_Umlenkstation_500mm]
for e in block_motor_rechts:
copy = e.copy()
copy.transform(matrix)
block_motor_links.add_entity(copy)
for e in block_umlenk_rechts:
copy = e.copy()
copy.transform(matrix)
block_umlenk_links.add_entity(copy)
if upper_hoehe_gefaehlle > lower_hoehe_gefaehlle:
if vario_hoehe_0 == upper_hoehe_gefaehlle or vario_hoehe_1 == upper_hoehe_gefaehlle:
hat_motor_0 = True
else:
hat_umlenk_0 = True
if upper_hoehe_gefaehlle < lower_hoehe_gefaehlle:
if vario_hoehe_0 == lower_hoehe_gefaehlle or vario_hoehe_1 == lower_hoehe_gefaehlle:
hat_motor_0 = True
else:
hat_umlenk_0 = 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
tefkurve_1 = gefaellestrecke_nachbarn.get("Tefkurve_1")
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_1 = True
else:
hat_umlenk_1 = 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_1 = True
else:
hat_umlenk_1 = True
blockname = f"Ils_2.0_Gefaellestrecke_{laenge}_{hoehe_gefaehlle}_{hat_motor_0}_{hat_umlenk_0}_{tefkurve_0}_{hat_motor_1}_{hat_umlenk_1}_{tefkurve_1}"
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_0 == False and hat_umlenk_0 == False and hat_motor_1 == False and hat_umlenk_1 == False:
laenge_m = merkmale.get("Länge in Meter", "10").replace(",", ".")
try:
laenge = float(laenge_m) * 1000 # Meter → mm
except ValueError:
laenge = 10000
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
line = msp.add_line(start,ende)
line.dxf.layer = "6-SP"
elif (hat_motor_0 == True and hat_umlenk_0 == False) and tefkurve_1 == None:
if blockname not in doc.blocks:
block = doc.blocks.new(name=blockname,base_point = (0,0,0))
if (hat_motor_0 == True and tefkurve_0 == "rechts") or (hat_motor_1 == True and tefkurve_1 == "rechts"):
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})
else:
block.add_blockref(blockname_motor_links, (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_0 == False and hat_umlenk_0 == True and tefkurve_1 == None:
if blockname not in doc.blocks:
block = doc.blocks.new(name=blockname,base_point = (0,0,0))
if (hat_umlenk_0 == True and tefkurve_0 == "rechts") or (hat_umlenk_1 == True and tefkurve_1 == "rechts"):
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})
else:
block.add_blockref(blockname_umlenk_links, (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[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})
else:
if blockname not in doc.blocks:
block = doc.blocks.new(name=blockname,base_point = (0,0,0))
if (hat_motor_0 == True and tefkurve_0 == "rechts") or (hat_motor_1 == True and tefkurve_1 == "rechts"):
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})
else:
block.add_blockref(blockname_motor_links, (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[2] = start[2] - 500* math.sin(math.radians(3))
if (hat_umlenk_0 == True and tefkurve_0 == "rechts") or (hat_umlenk_1 == True and tefkurve_1 == "rechts"):
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})
else:
block.add_blockref(blockname_umlenk_links, (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[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.
Parameter:
block ein ezdxf.blocks.BlockLayout Objekt
attributes Liste von Tupeln [(tag, value), ...]
"""
for tag, value in attributes.items():
tag = tag
value = value
a =block.add_attrib(
tag=tag,
text=value,
)
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"))
if merkmale.get("Laenge_Gefaellestrecke") != None:
gefahellewinkel =float(merkmale.get("Laenge_Gefaellestrecke"))
gefaelle = float(merkmale.get("Winkel_Gefaellestrecke"))
else:
gefahellewinkel = 0.0
gefaelle = 0.0
# Offsets für die Vario Linie für ab 3 bogen, da es in diesem Fall keine bögen hat die sich mit den nachbarn Bögen für andere Vario Förderer verbinden kann
winkel_VP_offset_vorne = None
winkel_VP_offset_hinten = None
# erstellung des Layers falls nicht vorhanden
if "VARIO" not in doc.layers:
doc.layers.add(name="VARIO", color=3)
if "6-SP" not in doc.layers:
doc.layers.add(name="6-SP", color=7)
# Vorbereitung der Werte
voerder_richtung = merkmale.get("Förderrichtung")
winkel = int(merkmale.get("Winkel"))
erster_kreisel_höher = False
ein_kreisel_höher = False
richtung2 ="DEFAULT"
rotation = float(merkmale.get("Drehung"))
upper_hoehe_vario= float(merkmale.get("Höhe Ende")) *1000
lower_hoehe_vario = float(merkmale.get("Höhe Anfang")) *1000
hoehe_vario= (upper_hoehe_vario + lower_hoehe_vario)/2
separatoren =float(merkmale.get("Anzahl der Separatoren"))
scanner = float(merkmale.get("Anzahl der Scanner"))
if rotation == 0 or rotation == -180:
ausrichtung = "V"
else:
ausrichtung = "H"
if ausrichtung == "V":
einsatz_fest = [x + 300,y,hoehe_vario]
modular = 2
else:
einsatz_fest = [x,y - 150,hoehe_vario]
modular = 3
block_scanner = "SCAN"
block_separatoren = "S-LP"
import_block(block_scanner,lib_doc,doc)
import_block(block_separatoren,lib_doc,doc)
einsatz_zwischen =[ einsatz_fest[0],einsatz_fest[1],einsatz_fest[2]]
anzahl =0
while anzahl < separatoren:
anzahl = anzahl + 1
msp.add_blockref(block_separatoren,einsatz_zwischen)
if anzahl % modular == 0:
einsatz_fest[1] = einsatz_fest[1] - 150
einsatz_zwischen = einsatz_fest.copy()
else:
einsatz_zwischen[0] = einsatz_zwischen[0]+ 300
if anzahl % modular != 0:
einsatz_fest[1] = einsatz_fest[1] - 150
einsatz_zwischen = einsatz_fest.copy()
anzahl =0
while anzahl < scanner:
anzahl = anzahl + 1
msp.add_blockref(block_scanner,einsatz_zwischen)
if anzahl % modular == 0:
einsatz_fest[1] = einsatz_fest[1] - 150
einsatz_zwischen = einsatz_fest.copy()
else:
einsatz_zwischen[0] = einsatz_zwischen[0]+ 300
# Umstellung der Höhen falls nötig für die Konsistenz der spätere Erstellung, ist nur notwendig für ab Vario Förderer
if upper_hoehe_vario< lower_hoehe_vario:
hight = upper_hoehe_vario
upper_hoehe_vario = lower_hoehe_vario
lower_hoehe_vario = hight
# Korrektur der rotation mit der Umstellung der Höhe
rotation = rotation -180
# Hollen der Information der Nachbarn strukturen ob diese Kreisel sind
for nachbarn in strecken_nachbarn:
if teileid == nachbarn.get("Id"):
gefaellestrecke_vario = nachbarn
break
laenge = float(merkmale.get("Länge in Meter")) *1000
# Ausrechnung der nötigen Offset falls der Vario Förderer ab mit drei grad mit einem anderen Verbunden ist
if (gefaellestrecke_vario.get("Winkel") != None or gefaellestrecke_vario.get("Kurvenrichtung") != None) and ((winkel == 3 and voerder_richtung == "Ab")or voerder_richtung == "Horizontal"):
# Überprüfung wo es verbunden ist und mit welchen fördere vorne ist ende der Fahrrichtung
if gefaellestrecke_vario.get("h0") != None:
if float(gefaellestrecke_vario.get("h0")) == lower_hoehe_vario:
if (gefaellestrecke_vario.get("Foerderrichtung") == "Auf" or gefaellestrecke_vario.get("Foerderrichtung") == "Horizontal"):
# Nehmen des winkels und diesen plus 3 nehmen, um den Bogen zu imporieren für heraufinden der Delta werte
winkel_vorne_plusbogen = int(gefaellestrecke_vario.get("Winkel")) +3
winkel_vorne = int(gefaellestrecke_vario.get("Winkel"))
blockname = (f"Vario_Bogen_ab_{winkel_vorne_plusbogen}°")
att_vorne =import_block(blockname,lib_doc,doc)
SP_1_nachbar_vorne = list(float(att)for att in re.split(r"[;,]", att_vorne["DELTA_SP_1"]))
VP_1_nachbar_vorne = list(float(att)for att in re.split(r"[;,]", att_vorne["DELTA_VP_1"]))
# Ausrechnen des Offsets
winkel_VP_offset_vorne = (SP_1_nachbar_vorne[0] - VP_1_nachbar_vorne[0]) * math.cos(math.radians(-winkel_vorne)) + (SP_1_nachbar_vorne[2] - VP_1_nachbar_vorne[2])*math.sin(math.radians(-winkel_vorne)), VP_1_nachbar_vorne[1],- (SP_1_nachbar_vorne[0] - VP_1_nachbar_vorne[0]) * math.sin(math.radians(-winkel_vorne)) + (SP_1_nachbar_vorne[2] - VP_1_nachbar_vorne[2])*math.cos(math.radians(-winkel_vorne))
elif gefaellestrecke_vario.get("Foerderrichtung") == "Ab":
# Nehmen des winkels und diesen minus 3 nehmen, um den Bogen zu imporieren für heraufinden der Delta werte
winkel_vorne_minusbogen = int(gefaellestrecke_vario.get("Winkel")) -3
winkel_vorne = int(gefaellestrecke_vario.get("Winkel"))
blockname = (f"Vario_Bogen_ab_{winkel_vorne_minusbogen}°")
att_vorne =import_block(blockname,lib_doc,doc)
SP_0_nachbar_vorne = list(float(att)for att in re.split(r"[;,]", att_vorne["DELTA_SP_0"]))
VP_0_nachbar_vorne = list(float(att)for att in re.split(r"[;,]", att_vorne["DELTA_VP_0"]))
# Ausrechnung des Offsets
winkel_VP_offset_vorne = (SP_0_nachbar_vorne[0] - VP_0_nachbar_vorne[0]) * math.cos(math.radians(3)) + (SP_0_nachbar_vorne[2] - VP_0_nachbar_vorne[2])*math.sin(math.radians(3)), VP_0_nachbar_vorne[1],- (SP_0_nachbar_vorne[0] - VP_0_nachbar_vorne[0]) * math.sin(math.radians(3)) + (SP_0_nachbar_vorne[2] - VP_0_nachbar_vorne[2])*math.cos(math.radians(3))
elif float(gefaellestrecke_vario.get("h1")) == upper_hoehe_vario:
if (gefaellestrecke_vario.get("Foerderrichtung") == "Auf" or gefaellestrecke_vario.get("Foerderrichtung") == "Horizontal"):
# Nehmen des winkels und diesen plus 3 nehmen, um den Bogen zu imporieren für heraufinden der Delta werte
winkel_hinten_plusbogen = int(gefaellestrecke_vario.get("Winkel")) +3
winkel_hinten = int(gefaellestrecke_vario.get("Winkel"))
blockname = (f"Vario_Bogen_auf_{winkel_hinten_plusbogen}°")
att_hinten =import_block(blockname,lib_doc,doc)
SP_0_nachbar_hinten = list(float(att)for att in re.split(r"[;,]", att_hinten["DELTA_SP_0"]))
VP_0_nachbar_hinten = list(float(att)for att in re.split(r"[;,]", att_hinten["DELTA_VP_0"]))
# Ausrechnung des Offsets
winkel_VP_offset_hinten = (SP_0_nachbar_hinten[0] - VP_0_nachbar_hinten[0]) * math.cos(math.radians(3)) + (SP_0_nachbar_hinten[2] - VP_0_nachbar_hinten[2])*math.sin(math.radians(3)), VP_0_nachbar_hinten[1],- (SP_0_nachbar_hinten[0] - VP_0_nachbar_hinten[0]) * math.sin(math.radians(3)) + (SP_0_nachbar_hinten[2] - VP_0_nachbar_hinten[2])*math.cos(math.radians(3))
else:
# Nehmen des winkels und diesen minus 3 nehmen, um den Bogen zu imporieren für heraufinden der Delta werte
winkel_hinten_minusbogen = int(gefaellestrecke_vario.get("Winkel")) -3
winkel_hinten = int(gefaellestrecke_vario.get("Winkel"))
blockname = (f"Vario_Bogen_auf_{winkel_hinten_minusbogen}°")
att_hinten =import_block(blockname,lib_doc,doc)
SP_1_nachbar_hinten = list(float(att)for att in re.split(r"[;,]", att_hinten["DELTA_SP_1"]))
VP_1_nachbar_hinten = list(float(att)for att in re.split(r"[;,]", att_hinten["DELTA_VP_1"]))
# Ausrechnung des Offsets
winkel_VP_offset_hinten = (SP_1_nachbar_hinten[0] - VP_1_nachbar_hinten[0]) * math.cos(math.radians(winkel_hinten)) + (SP_1_nachbar_hinten[2] - VP_1_nachbar_hinten[2])*math.sin(math.radians(winkel_hinten)), VP_1_nachbar_hinten[1],- (SP_1_nachbar_hinten[0] - VP_1_nachbar_hinten[0]) * math.sin(math.radians(winkel_hinten)) + (SP_1_nachbar_hinten[2] - VP_1_nachbar_hinten[2])*math.cos(math.radians(winkel_hinten))
# Das gleiche falls der 3 grad Förderer mit zwei Förderer Verbunden ist
if (gefaellestrecke_vario.get("Winkel_2") != None or gefaellestrecke_vario.get("Kurvenrichtung")!= None):
# Überprüfung wo es verbunden ist und mit welchen fördere vorne ist ende der Fahrrichtung
if gefaellestrecke_vario.get("h0_2") != None:
if float(gefaellestrecke_vario.get("h0_2")) == lower_hoehe_vario:
if (gefaellestrecke_vario.get("Foerderrichtung_2") == "Auf" or gefaellestrecke_vario.get("Foerderrichtung_2") == "Horizontal"):
# Nehmen des winkels und diesen plus 3 nehmen, um den Bogen zu imporieren für heraufinden der Delta werte
winkel_vorne_plusbogen = int(gefaellestrecke_vario.get("Winkel_2")) +3
winkel_vorne = int(gefaellestrecke_vario.get("Winkel_2"))
blockname = (f"Vario_Bogen_ab_{winkel_vorne_plusbogen}°")
att_vorne =import_block(blockname,lib_doc,doc)
SP_1_nachbar_vorne = list(float(att)for att in re.split(r"[;,]", att_vorne["DELTA_SP_1"]))
VP_1_nachbar_vorne = list(float(att)for att in re.split(r"[;,]", att_vorne["DELTA_VP_1"]))
# Ausrechnung des Offsets
winkel_VP_offset_vorne = (SP_1_nachbar_vorne[0] - VP_1_nachbar_vorne[0]) * math.cos(math.radians(-winkel_vorne)) + (SP_1_nachbar_vorne[2] - VP_1_nachbar_vorne[2])*math.sin(math.radians(-winkel_vorne)), VP_1_nachbar_vorne[1],- (SP_1_nachbar_vorne[0] - VP_1_nachbar_vorne[0]) * math.sin(math.radians(-winkel_vorne)) + (SP_1_nachbar_vorne[2] - VP_1_nachbar_vorne[2])*math.cos(math.radians(-winkel_vorne))
else:
# Nehmen des winkels und diesen minus 3 nehmen, um den Bogen zu imporieren für heraufinden der Delta werte
winkel_vorne_minusbogen = int(gefaellestrecke_vario.get("Winkel_2")) -3
winkel_vorne = int(gefaellestrecke_vario.get("Winkel_2"))
blockname = (f"Vario_Bogen_ab_{winkel_vorne_minusbogen}°")
att_vorne =import_block(blockname,lib_doc,doc)
SP_0_nachbar_vorne = list(float(att)for att in re.split(r"[;,]", att_vorne["DELTA_SP_0"]))
VP_0_nachbar_vorne = list(float(att)for att in re.split(r"[;,]", att_vorne["DELTA_VP_0"]))
# Ausrechnung des Offsets
winkel_VP_offset_vorne = (SP_0_nachbar_vorne[0] - VP_0_nachbar_vorne[0]) * math.cos(math.radians(3)) + (SP_0_nachbar_vorne[2] - VP_0_nachbar_vorne[2])*math.sin(math.radians(3)), VP_0_nachbar_vorne[1],- (SP_0_nachbar_vorne[0] - VP_0_nachbar_vorne[0]) * math.sin(math.radians(3)) + (SP_0_nachbar_vorne[2] - VP_0_nachbar_vorne[2])*math.cos(math.radians(3))
elif float(gefaellestrecke_vario.get("h1_2")) == upper_hoehe_vario:
if (gefaellestrecke_vario.get("Foerderrichtung_2") == "Auf" or gefaellestrecke_vario.get("Foerderrichtung_2") == "Horizontal"):
# Nehmen des winkels und diesen plus 3 nehmen, um den Bogen zu imporieren für heraufinden der Delta werte
winkel_hinten_plusbogen = int(gefaellestrecke_vario.get("Winkel_2")) +3
blockname = (f"Vario_Bogen_auf_{winkel_hinten_plusbogen}°")
att_hinten =import_block(blockname,lib_doc,doc)
SP_0_nachbar_hinten = list(float(att)for att in re.split(r"[;,]", att_hinten["DELTA_SP_0"]))
VP_0_nachbar_hinten = list(float(att)for att in re.split(r"[;,]", att_hinten["DELTA_VP_0"]))
# Ausrechnung des Offsets
winkel_VP_offset_hinten = (SP_0_nachbar_hinten[0] - VP_0_nachbar_hinten[0]) * math.cos(math.radians(3)) + (SP_0_nachbar_hinten[2] - VP_0_nachbar_hinten[2])*math.sin(math.radians(3)), VP_0_nachbar_hinten[1],- (SP_0_nachbar_hinten[0] - VP_0_nachbar_hinten[0]) * math.sin(math.radians(3)) + (SP_0_nachbar_hinten[2] - VP_1_nachbar_hinten[2])*math.cos(math.radians(3))
else:
# Nehmen des winkels und diesen minus 3 nehmen, um den Bogen zu imporieren für heraufinden der Delta werte
winkel_hinten_minusbogen = int(gefaellestrecke_vario.get("Winkel")) -3
winkel_hinten = int(gefaellestrecke_vario.get("Winkel_2"))
blockname = (f"Vario_Bogen_auf_{winkel_hinten_minusbogen}°")
att_hinten =import_block(blockname,lib_doc,doc)
SP_1_nachbar_hinten = list(float(att)for att in re.split(r"[;,]", att_hinten["DELTA_SP_1"]))
VP_1_nachbar_hinten = list(float(att)for att in re.split(r"[;,]", att_hinten["DELTA_VP_1"]))
# Ausrechnung des Offsets
winkel_VP_offset_hinten = ((SP_1_nachbar_hinten[0] - VP_1_nachbar_hinten[0]) * math.cos(math.radians(winkel_hinten)) + (SP_1_nachbar_hinten[2] - VP_1_nachbar_hinten[2])*math.sin(math.radians(winkel_hinten))), VP_1_nachbar_hinten[1],- (SP_1_nachbar_hinten[0] - VP_1_nachbar_vorne[0]) * math.sin(math.radians(winkel_hinten)) + (SP_1_nachbar_hinten[2] - VP_1_nachbar_hinten[2])*math.cos(math.radians(winkel_hinten))
# Für spätere berechnung schauen ob der erste Kreis in der Liste höher ist
if upper_hoehe_vario == gefaellestrecke_vario.get("Hoehe0"):
ein_kreisel_höher = True
# Aufruf falls nur mit einem Kreisel verbunden
if "Drehung0" in gefaellestrecke_vario and "Drehung1" not in gefaellestrecke_vario:
# Vorbereitund der Daten des Kreisel
halbe_laenge = laenge / 2
zwischen_winkel = float(merkmale.get("Drehung"))
richtung_rad = math.radians(zwischen_winkel)
dx = halbe_laenge * math.sin(-1 *richtung_rad)
dy = halbe_laenge * math.cos(richtung_rad)
drehung0 = gefaellestrecke_vario.get("Drehung0")
abstand0 = float(gefaellestrecke_vario.get("abstand0")) * 1000
x0_kreisel = float(gefaellestrecke_vario.get("x0"))
y0_kreisel = float(gefaellestrecke_vario.get("y0"))
richtung0 = float(gefaellestrecke_vario.get("rotation0"))
richtung_rad0= math.radians(richtung0)
# Herausfinden ob der Förderere direkt mit dem Kreisel verbunden ist, die Werte für den Zweiten Kreisel wird auf None gesetzt weil diese nicht existieren
mit_horizontal_verbunden = None
if voerder_richtung == "Horizontal":
if rotation == 0.0:
if y> y0_kreisel:
mit_horizontal_verbunden = "unten_drehung_0_or_-90"
else:
mit_horizontal_verbunden = "oben_drehung_0_or_-90"
if rotation == -180.0:
if y> y0_kreisel:
mit_horizontal_verbunden = "unten_drehung_-180_or_-270"
else:
mit_horizontal_verbunden = "oben_drehung_-180_or_-270"
if rotation == -90.0:
if x> x0_kreisel:
mit_horizontal_verbunden = "unten_drehung_0_or_-90"
else:
mit_horizontal_verbunden = "oben_drehung_0_or_-90"
if rotation == -270.0:
if x> x0_kreisel:
mit_horizontal_verbunden = "unten_drehung_-180_or_-270"
else:
mit_horizontal_verbunden = "oben_drehung_-180_or_-270"
am_kreisel,kreseil_verbunden =am_kreisel_direct_verbunden(x, y, upper_hoehe_vario, lower_hoehe_vario, x0_kreisel, y0_kreisel, richtung_rad0, abstand0, dx, dy, None, None, None, None )
if am_kreisel == 1:
# Erstellung der blockname für wenn die Motorstation rechts und links
blockname = (f"Vario_Foerderer_{winkel}_{voerder_richtung}_{laenge}_{hoehe_vario}_rechts_{ein_kreisel_höher}_{drehung0}_True_{motor_vorhanden}_{umlenk_vorhanden}_{gefaelle}_{gefahellewinkel}_{mit_horizontal_verbunden}")
block_name_links = (f"Vario_Foerderer_{winkel}_{voerder_richtung}_{laenge}_{hoehe_vario}_links_{ein_kreisel_höher}_{drehung0}_True_{motor_vorhanden}_{umlenk_vorhanden}_{gefaelle}_{gefahellewinkel}_{mit_horizontal_verbunden}")
# Falls der Block bereits in dem doc ist platziere diesen einfach
if blockname in doc.blocks:
if merkmale.get("Motorseite")== "links":
msp.add_blockref(block_name_links,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
elif merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
# Erstellung des Blocks und diesen in die Modelspace tuen. Die Linke version wird bei der vario erstellung selber am ende gemacht
block_vario = doc.blocks.new(blockname, base_point=(0,0,0))
dy_true = halbe_laenge * math.cos (0)
start = (x, y + dy_true,upper_hoehe_vario)
ende = (x,y -dy_true,lower_hoehe_vario)
# Erstellung einer Gefällestrecke von 500 mm in der Vario rein, wo es verbunden ist
if ein_kreisel_höher == True and voerder_richtung != "Horizontal":
l = (start[0],start[1],upper_hoehe_vario)
if voerder_richtung =="Auf":
m = (start[0],start[1] - 500*math.cos(math.radians(3)),upper_hoehe_vario +500* math.sin(math.radians(3)))
start = m
elif voerder_richtung == "Ab":
m = (start[0],start[1] - 500*math.cos(math.radians(3)),upper_hoehe_vario - 500* math.sin(math.radians(3)))
start = m
else:
if mit_horizontal_verbunden == "unten_drehung_0_or_-90" or mit_horizontal_verbunden == "oben_drehung_-180_or_-270":
m = (start[0],start[1] - 500*math.cos(math.radians(3)),upper_hoehe_vario+500* math.sin(math.radians(3)))
start = m
else:
en = (ende[0],ende[1] + 500*math.cos(math.radians(3)) ,lower_hoehe_vario- 500* math.sin(math.radians(3)) )
ende = en
line = Line.new(dxfattribs={"start": l,"end":m })
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_vario)
block_vario.add_entity(copy)
elif ein_kreisel_höher == False and voerder_richtung != "Horizontal":
l = (ende[0],ende[1],lower_hoehe_vario)
if voerder_richtung =="Auf":
m = (ende[0],ende[1] + 500*math.cos(math.radians(3)) ,lower_hoehe_vario - 500* math.sin(math.radians(3)))
ende = m
elif voerder_richtung == "Ab":
m = (ende[0],ende[1] + 500*math.cos(math.radians(3)) ,lower_hoehe_vario + 500* math.sin(math.radians(3)))
ende = m
else:
m = (ende[0],ende[1] + 500*math.cos(math.radians(3)) ,lower_hoehe_vario )
ende = m
line = Line.new(dxfattribs={"start": l,"end":m })
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_vario)
block_vario.add_entity(copy)
elif voerder_richtung == "Horizontal":
if mit_horizontal_verbunden == "oben_drehung_0_or_-90" or mit_horizontal_verbunden == "unten_drehung_-180_or_-270":
l = (start[0],start[1],upper_hoehe_vario)
m = (start[0],start[1] - 500*math.cos(math.radians(3)),upper_hoehe_vario)
start = m
line = Line.new(dxfattribs={"start": l,"end":m })
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_vario)
block_vario.add_entity(copy)
else:
end = (ende[0],ende[1],lower_hoehe_vario)
en = (ende[0],ende[1] + 500*math.cos(math.radians(3)) ,lower_hoehe_vario )
ende = en
line = Line.new(dxfattribs={"start": end,"end":en })
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_vario)
block_vario.add_entity(copy)
# Erstellung des Vario_förderes selber
vario_erstellung(msp,merkmale, x, y, doc, lib_doc, config, winkel, hoehe_vario, laenge, block_vario,block_name_links, start, ende,voerder_richtung ,winkel_VP_offset_vorne,winkel_VP_offset_hinten)
# reintuen des förderes in den Modelspace
if merkmale.get("Motorseite")== "links":
msp.add_blockref(block_name_links,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
elif merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
# Abschnitt falls der Vario nur mit einem Kreisel verbunden ist und nicht an dem Kreisel direkt verbunden ist
# Erstellung der blockname für wenn die Motorstation rechts und links
blockname = (f"Vario_Foerderer_{winkel}_{voerder_richtung}_{laenge}_{hoehe_vario}_rechts_{ein_kreisel_höher}_{drehung0}_{motor_vorhanden}_{umlenk_vorhanden}_{gefaelle}_{gefahellewinkel}_{mit_horizontal_verbunden}")
block_name_links = (f"Vario_Foerderer_{winkel}_{voerder_richtung}_{laenge}_{hoehe_vario}_links_{ein_kreisel_höher}_{drehung0}_{motor_vorhanden}_{umlenk_vorhanden}_{gefaelle}_{gefahellewinkel}_{mit_horizontal_verbunden}")
# Falls der Block bereits in dem doc ist platziere diesen einfach
if blockname in doc.blocks:
if merkmale.get("Motorseite")== "links":
msp.add_blockref(block_name_links,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
elif merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
# Erstellung des Blocks und diesen in die Modelspace tuen. Die Linke version wird bei der vario erstellung selber am ende gemacht
block_vario = doc.blocks.new(blockname, base_point=(0,0,0))
dy_true = halbe_laenge * math.cos (0)
# Schauen welches as oder es element man wo verbinden muss und bereits in den block tuen, der None wert ist ein Wert der für die Gefällestrecke notwendig ist
# Entnehmen von start und end Werte für spätere vario erstellung
start, ende =erstellung_gefaelle_block_verbunenden_am_einen(msp,x, y, doc, lib_doc, upper_hoehe_vario, lower_hoehe_vario, hoehe_vario, drehung0, laenge, blockname,config,None ,block_vario, voerder_richtung, ein_kreisel_höher,None,None,None,mit_horizontal_verbunden)
# Erstellung des Varios selber
vario_erstellung(msp,merkmale, x, y, doc, lib_doc, config, winkel, hoehe_vario, laenge, block_vario,block_name_links, start, ende,voerder_richtung ,winkel_VP_offset_vorne,winkel_VP_offset_hinten)
# reintuen des förderes in den Modelspace
if merkmale.get("Motorseite")== "links":
msp.add_blockref(block_name_links,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
if merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
# Erstellung einer Vario förderes wenn es mit zwei Kreisel verbunden ist
elif "Drehung0" in gefaellestrecke_vario and "Drehung1" in gefaellestrecke_vario:
# Vorbereitung der Werte für beide Kreisel
halbe_laenge = laenge / 2
zwischen_winkel = float(merkmale.get("Drehung"))
richtung_rad = math.radians(zwischen_winkel)
dx = halbe_laenge * math.sin(-1 *richtung_rad)
dy = halbe_laenge * math.cos(richtung_rad)
drehung0 = gefaellestrecke_vario.get("Drehung0")
abstand0 = float(gefaellestrecke_vario.get("abstand0")) * 1000
x0_kreisel = float(gefaellestrecke_vario.get("x0"))
y0_kreisel = float(gefaellestrecke_vario.get("y0"))
richtung0 = float(gefaellestrecke_vario.get("rotation0"))
richtung_rad0= math.radians(richtung0)
kreisel_hoehe0 =float(gefaellestrecke_vario.get("Hoehe0"))
drehung1 = gefaellestrecke_vario.get("Drehung1")
abstand1 = float(gefaellestrecke_vario.get("abstand1")) * 1000
x1_kreisel = float(gefaellestrecke_vario.get("x1"))
y1_kreisel = float(gefaellestrecke_vario.get("y1"))
richtung1 = float(gefaellestrecke_vario.get("rotation1"))
richtung_rad1= math.radians(richtung1)
kreisel_hoehe1= float(gefaellestrecke_vario.get("Hoehe1"))
# Anpassung der Kreisel, damit der Höhere Kreisel immer zuerst ist
if kreisel_hoehe0< kreisel_hoehe1:
drehung2 = drehung0
drehung0 = drehung1
drehung1 = drehung2
# Schauen ob der Förderer direkt am Kreisel verbunden ist
am_kreisel,kreisel_verbunden =am_kreisel_direct_verbunden(x, y, upper_hoehe_vario, lower_hoehe_vario, x0_kreisel, y0_kreisel, richtung_rad0, abstand0, dx, dy, x1_kreisel, y1_kreisel, richtung_rad1, abstand1)
# Falls der Förder mit beiden Kreisel verbunden ist
if kreisel_verbunden == 2:
# Erstellung der blockname für wenn die Motorstation rechts und links
blockname = (f"Vario_Foerderer_{winkel}_{voerder_richtung}_{laenge}_{hoehe_vario}_rechts_{drehung0}_{drehung1}_{kreisel_verbunden}_{motor_vorhanden}_{umlenk_vorhanden}_{gefaelle}_{gefahellewinkel}")
block_name_links = (f"Vario_Foerderer_{winkel}_{voerder_richtung}_{laenge}_{hoehe_vario}_links_{drehung0}_{drehung1}_{kreisel_verbunden}_{motor_vorhanden}_{umlenk_vorhanden}_{gefaelle}_{gefahellewinkel}")
# Falls der Block bereits in dem doc ist platziere diesen einfach
if blockname in doc.blocks:
if merkmale.get("Motorseite")== "links":
msp.add_blockref(block_name_links,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
elif merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
# Erstellung des Blocks und diesen in die Modelspace tuen. Die Linke version wird bei der vario erstellung selber am ende gemacht
block_vario = doc.blocks.new(blockname, base_point=(0,0,0))
dy_true = halbe_laenge * math.cos (0)
start = (x, y + dy_true,upper_hoehe_vario)
ende = (x,y -dy_true,lower_hoehe_vario)
l = (start[0],start[1],upper_hoehe_vario)
# Eine 500 mm gefällestrecke an anfang und am ende reintuen
if voerder_richtung =="Auf":
m = (start[0],start[1] - 500*math.cos(math.radians(3)),upper_hoehe_vario +500* math.sin(math.radians(3)))
start = m
elif voerder_richtung == "Ab":
m = (start[0],start[1] - 500*math.cos(math.radians(3)),upper_hoehe_vario -500* math.sin(math.radians(3)))
start = m
else:
m = (start[0],start[1] - 500*math.cos(math.radians(3)),upper_hoehe_vario )
start = m
line = Line.new(dxfattribs={"start": l,"end":m })
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_vario)
block_vario.add_entity(copy)
l = (ende[0],ende[1],lower_hoehe_vario)
if voerder_richtung =="Auf":
m = (ende[0],ende[1] + 500*math.cos(math.radians(3)) ,lower_hoehe_vario - 500* math.sin(math.radians(3)))
ende = m
elif voerder_richtung == "Ab":
m = (ende[0],ende[1] + 500*math.cos(math.radians(3)) ,lower_hoehe_vario + 500* math.sin(math.radians(3)))
ende = m
else:
m = (ende[0],ende[1] + 500*math.cos(math.radians(3)) ,lower_hoehe_vario )
ende = m
line = Line.new(dxfattribs={"start": l,"end":m })
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_vario)
block_vario.add_entity(copy)
# Die Vario erstellung selber
vario_erstellung(msp,merkmale, x, y, doc, lib_doc, config, winkel, hoehe_vario, laenge, block_vario,block_name_links, start, ende,voerder_richtung ,winkel_VP_offset_vorne,winkel_VP_offset_hinten)
# reintuen des förderes in den Modelspace
if merkmale.get("Motorseite")== "links":
msp.add_blockref(block_name_links,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
elif merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
# Falls der Förderer nur mit einem Kreisel direkt verbunden ist
if am_kreisel != 0:
#schauen ob der erste Kreisel höher ist
if upper_hoehe_vario == kreisel_hoehe0:
erster_kreisel_höher = True
else:
erster_kreisel_höher = False
# Erstellung der blockname für wenn die Motorstation rechts und links
blockname = (f"Vario_Foerderer_{winkel}_{voerder_richtung}_{laenge}_{hoehe_vario}_rechts_{am_kreisel}_{erster_kreisel_höher}_{drehung0}_{drehung1}_{motor_vorhanden}_{umlenk_vorhanden}_{gefaelle}_{gefahellewinkel}")
block_name_links = (f"Vario_Foerderer_{winkel}_{voerder_richtung}_{laenge}_{hoehe_vario}_links_{am_kreisel}_{erster_kreisel_höher}_{drehung0}_{drehung1}_{motor_vorhanden}_{umlenk_vorhanden}_{gefaelle}_{gefahellewinkel}")
# Falls der Block bereits in dem doc ist platziere diesen einfach
if blockname in doc.blocks:
if merkmale.get("Motorseite")== "links":
msp.add_blockref(block_name_links,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
elif merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
# Erstellung des Blocks und diesen in die Modelspace tuen. Die Linke version wird bei der vario erstellung selber am ende gemacht
block_vario = doc.blocks.new(blockname, base_point=(0,0,0))
dy_true = halbe_laenge * math.cos(0)
# schauen ob der Förderer mit welchen Kreisel der Förderer verbunden ist, und dem entsprechend eine Gefällestrecke dort reintuern
if (am_kreisel == 1 and erster_kreisel_höher == True)or (am_kreisel == 2 and erster_kreisel_höher == False):
start = (x, y + dy_true,upper_hoehe_vario)
ende = (x,y -dy_true,lower_hoehe_vario)
l = (start[0],start[1],upper_hoehe_vario)
if voerder_richtung == "Auf":
m = (start[0],start[1] - 500*math.cos(math.radians(3)),upper_hoehe_vario +500* math.sin(math.radians(3)))
z1 = m[2]
elif voerder_richtung == "Ab":
m = (start[0],start[1] - 500*math.cos(math.radians(3)),upper_hoehe_vario -500* math.sin(math.radians(3)))
z1 = m[2]
else:
m= (x,y -dy_true,lower_hoehe_vario)
z1 = m[2]
line = Line.new(dxfattribs={"start": l,"end":m })
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_vario)
block_vario.add_entity(copy)
y1 = start[1] - math.cos(math.radians(3)) *500
else:
start = (x, y + dy_true,upper_hoehe_vario)
ende = (x,y -dy_true,lower_hoehe_vario)
l = (ende[0],ende[1],lower_hoehe_vario)
if voerder_richtung =="Auf":
m = (ende[0],ende[1] + 500*math.cos(math.radians(3)) ,lower_hoehe_vario - 500* math.sin(math.radians(3)))
z1 = m[2]
elif voerder_richtung == "Ab":
m = (ende[0],ende[1] + 500*math.cos(math.radians(3)) ,lower_hoehe_vario + 500* math.sin(math.radians(3)))
z1 = m[2]
else:
m = (ende[0],ende[1] + 500*math.cos(math.radians(3)) ,lower_hoehe_vario )
z1 = m[2]
line = Line.new(dxfattribs={"start": l,"end":m })
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_vario)
block_vario.add_entity(copy)
y1 = ende[1] + math.cos(math.radians(3)) *500
# Schauen welche es oder as element man braucht man braucht und diese in den block einfügen
# Entnehmen von start und end Werte für spätere vario erstellung
start, ende =gefaellegerade_erstellung(x, y, doc, lib_doc, upper_hoehe_vario, lower_hoehe_vario, hoehe_vario,richtung2, drehung0, drehung1, laenge, None, blockname,config,block_vario,voerder_richtung, am_kreisel,erster_kreisel_höher,y1,z1)
# Erstellung der Vario gefälle selber
vario_erstellung(msp,merkmale, x, y, doc, lib_doc, config, winkel, hoehe_vario, laenge, block_vario,block_name_links, start, ende,voerder_richtung ,winkel_VP_offset_vorne,winkel_VP_offset_hinten)
# Reintuen des endblockes in den Modelspace
if merkmale.get("Motorseite")== "links":
msp.add_blockref(block_name_links,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
elif merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
# Falls es nicht mit dem Kreisel direkt verbunden ist
else:
# Erstellung der blockname für wenn die Motorstation rechts und links
blockname = (f"Vario_Foerderer_{winkel}_{voerder_richtung}_{laenge}_{hoehe_vario}_rechts_{drehung0}_{drehung1}_{motor_vorhanden}_{umlenk_vorhanden}_{gefaelle}_{gefahellewinkel}")
block_name_links = (f"Vario_Foerderer_{winkel}_{voerder_richtung}_{laenge}_{hoehe_vario}_links_{drehung0}_{drehung1}_{motor_vorhanden}_{umlenk_vorhanden}_{gefaelle}_{gefahellewinkel}")
# Falls der Block bereits in dem doc ist platziere diesen einfach
if blockname in doc.blocks:
if merkmale.get("Motorseite")== "links":
msp.add_blockref(block_name_links,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
elif merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
# Erstellung des Blocks und diesen in die Modelspace tuen. Die Linke version wird bei der vario erstellung selber am ende gemacht
block_vario = doc.blocks.new(blockname, base_point=(0,0,0))
# Schauen welche es oder as element man braucht man braucht und diese in den block einfügen
# Entnehmen von start und end Werte für spätere vario erstellung
start, ende =gefaellegerade_erstellung(x, y, doc, lib_doc, upper_hoehe_vario, lower_hoehe_vario, hoehe_vario,richtung2, drehung0, drehung1, laenge, None, blockname,cofig,block_vario,voerder_richtung)
# Erstellung des Vario selber
vario_erstellung(msp,merkmale, x, y, doc, lib_doc, config, winkel, hoehe_vario, laenge, block_vario,block_name_links, start, ende,voerder_richtung,winkel_VP_offset_vorne,winkel_VP_offset_hinten )
# Reintuen des endblockes in den Modelspace
if merkmale.get("Motorseite")== "links":
msp.add_blockref(block_name_links,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
elif merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
# Erstellung des Varios falls es nicht mit einem Kreisel verbunden ist
else:
halbe_laenge = laenge/2
dy = halbe_laenge * math.cos(0)
# Erstellung der blockname für wenn die Motorstation rechts und links
blockname = (f"Vario_Foerderer_{winkel}_{voerder_richtung}_{laenge}_{hoehe_vario}_rechts_{motor_vorhanden}_{umlenk_vorhanden}_{gefaelle}_{gefahellewinkel}")
block_name_links =(f"Vario_Foerderer_{winkel}_{voerder_richtung}_{laenge}_{hoehe_vario}_links_{motor_vorhanden}_{umlenk_vorhanden}_{gefaelle}_{gefahellewinkel}")
# Falls der Block bereits in dem doc ist platziere diesen einfach
if blockname in doc.blocks:
if merkmale.get("Motorseite")== "links":
msp.add_blockref(block_name_links,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
elif merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
# Erstellung des Blocks und diesen in die Modelspace tuen. Die Linke version wird bei der vario erstellung selber am ende gemacht
block = doc.blocks.new(blockname, base_point=(0,0,0))
# Erstellung von start und ende
start = (x,y +dy, upper_hoehe_vario)
ende = (x ,y -dy, lower_hoehe_vario)
# Erstellung des Förderes selber
vario_erstellung(msp,merkmale, x, y, doc, lib_doc, config, winkel, hoehe_vario, laenge, block,block_name_links, start, ende,voerder_richtung ,winkel_VP_offset_vorne,winkel_VP_offset_hinten)
# Reintuen des endblockes in den Modelspace
if merkmale.get("Motorseite")== "links":
msp.add_blockref(block_name_links,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
if merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
def handle_ils_2_0_kurve_angetrieben(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
kurvenrichtung = merkmale.get("Kurvenrichtung")
kurvenwinkel = int(merkmale.get("Kurvenwinkel"))
h0 = float(merkmale.get("Höhe Anfang"))* 1000
h1 = float(merkmale.get("Höhe Ende")) * 1000
h_zwischen = (h0 +h1)/2
antriebNebenStrecke = merkmale.get("AntriebNebenStrecke")
if antriebNebenStrecke == "links":
if kurvenrichtung == "links":
antriebstecke = "innen"
else:
antriebstecke = "außen"
else:
if kurvenrichtung == "links":
antriebstecke = "außen"
else:
antriebstecke = "innen"
rotation = float(merkmale.get("Drehung"))
blockname = (f"Vario_Kurve_{kurvenrichtung}_{kurvenwinkel}°_TEF_{antriebstecke}")
import_block(blockname,lib_doc,doc)
msp.add_blockref(blockname,(x,y,h_zwischen),dxfattribs={"rotation": rotation})
def handle_ils_2_0_kurve(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
import_block("AN8",lib_doc,doc)
msp.add_blockref("AN8",(x,y))
def handle_bt___beladung(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
import_block("AN8",lib_doc,doc)
msp.add_blockref("AN8",(x,y))
def handle_bt___entladung(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
import_block("AN8",lib_doc,doc)
msp.add_blockref("AN8",(x,y))
def handle_omniflo(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
"""
Für Omniflo Gerade: zeichnet eine Linie (Mitte = Koordinate, Länge und Winkel aus Merkmale).
Für alle anderen Omniflo-Typen: Block mit SivasNummer an den Koordinaten.
"""
# Prüfen, ob es sich um eine Gerade handelt
omnisivas = config.get("Omniflo","OFgeradesivas")
tefsivas = config.get("Omniflo","Tefgeradesivas")
foerderer = config.get("Omniflo","OFfoerderer")
if merkmale.get("SivasNummer") == omnisivas or merkmale.get("SivasNummer") == tefsivas:
try:
laenge = float(merkmale.get("Länge in Meter", "0").replace(",", ".")) * 1000 # Meter → mm
except Exception:
laenge = 0
try:
winkel = float(merkmale.get("Drehung"))
except Exception:
winkel = 0.0
winkel_rad = math.radians(winkel)
halbe_laenge = laenge / 2
# Man muss bei sin -1 machen wegen des links koordinaten system
dx = halbe_laenge * math.sin(winkel_rad * -1)
dy = halbe_laenge * math.cos(winkel_rad)
start = (x + dx, y + dy, float(merkmale.get("Höhe oben")) )
ende = (x - dx, y - dy, float(merkmale.get("Höhe unten")))
if "A-2" not in doc.layers:
doc.layers.add(name="A-2", color=2)
if "F-1" not in doc.layers:
doc.layers.add(name="F-1", color =1)
linie=msp.add_line(start, ende)
if merkmale.get("SivasNummer") == tefsivas:
linie.dxf.layer = "F-1"
else:
linie.dxf.layer = "A-2"
if verbose:
print(f"[INFO] Omniflo Gerade → {teileid} Linie von ({start[0]:.1f}, {start[1]:.1f}) nach ({ende[0]:.1f}, {ende[1]:.1f})")
return
if merkmale.get("SivasNummer") == foerderer:
import_block("bogen1",lib_doc,doc)
import_block("bogen2",lib_doc,doc)
rotation = float(merkmale.get("Drehung"))
laenge = float(merkmale.get("laenge in meter")) * 1000
h0 = float(merkmale.get("Höhe unten"))
h1 = float(merkmale.get("Höhe oben"))
h_zwischen = (h0 + h1)/2
blockname = (f"OF_Förderer_{laenge}_{h_zwischen}")
winkel_rad = math.radians(rotation)
halbe_laenge = laenge / 2
# Man muss bei sin -1 machen wegen des links koordinaten system
dx = halbe_laenge * math.sin(rotation * -1)
dy = halbe_laenge * math.cos(rotation)
start = (x + dx, y + dy, float(merkmale.get("Höhe oben")) )
ende = (x - dx, y - dy, float(merkmale.get("Höhe unten")))
if blockname not in doc.blocks:
block = doc.blocks.new(blockname, base_point=(0,0,0))
block.add_blockref("bogen1",start)
block.add_blockref("bogen2",ende)
line = Line.new(dxfattribs={"start": start,"end":ende})
copy = line.copy()
copy.translate(-x,-y,-h_zwischen)
block.add_entity(copy)
msp.add_blockref(blockname,(x,y,h_zwischen),dxfattribs={"rotation": rotation})
return
# Sonst wie gehabt: Block mit SivasNummer
if not lib_doc:
print("[WARN] lib_doc nicht verfügbar, Block wird nicht eingefügt.")
return
blockname = merkmale.get("SivasNummer")
if not blockname:
print(f"[WARN] Keine SivasNummer für {teileid}, überspringe.")
return
if blockname not in lib_doc.blocks:
print(f"[WARN] Omniflo-Block '{blockname}' nicht in Bibliothek {lib_doc.filename}. Überspringe {teileid}.")
return
blockname = blockname
drehung = merkmale.get("Drehung")
import_block(blockname, lib_doc, doc)
# blockref_layer = get_layer(doc, lib_doc, blockname)
symblos_layers = config_allgemein.get("dxf2lib","automation_layer")
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, upper_hoehe_gefaehlle, lower_hoehe_gefaehlle, hoehe_gefaehlle, drehung0, laenge,blockname,config, hight = None, block_vario = None, vario_richtung = None, verbungden_höher = None,gefaelle_block=None,start = None,ende = None,mit_horizontal_verbunden = None):
halbe_laenge = laenge / 2
dy = halbe_laenge * math.cos(0)
asoffset = float(config.get("ILS 2.0 Gefällestrecke", "asoffset"))
esoffset = float(config.get("ILS 2.0 Gefällestrecke", "esoffset"))
winkel_as = float(config.get("Ils 2.0 core winkel", "winkel_as"))
winkel_es = float(config.get("Ils 2.0 core winkel", "winkel_es"))
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")or (vario_richtung == "Horizontal" and drehung0 == "GUZS" and (mit_horizontal_verbunden == "unten_drehung_0_or_-90" or mit_horizontal_verbunden == "oben_drehung_-180_or_-270"))):
block_as = "200000241_AS-Element_90_rechts"
import_block(block_as,lib_doc,doc)
# block_as = dreh_block(block_as,doc,math.radians(winkel_as))
# asoffset_y = asoffset * math.cos(math.radians(winkel_as))
# asoffset_z = asoffset * math.sin(math.radians(winkel_as))
if vario_richtung == "Auf":
start = (x , y + dy ,upper_hoehe_gefaehlle)
ende = (x , y - dy + asoffset ,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_as,(ende[0]-x ,ende[1]-asoffset -y,ende[2] -hoehe_gefaehlle ),dxfattribs={"rotation": 180})
return start, ende
elif vario_richtung == "Ab":
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle )
ende = (x , y - dy ,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] -hoehe_gefaehlle ))
return start,ende
elif vario_richtung =="Horizontal":
start = (x , y + dy ,upper_hoehe_gefaehlle)
ende = (x , y - dy + asoffset ,lower_hoehe_gefaehlle )
block_vario.add_blockref(block_as,(ende[0]-x ,ende[1]-asoffset -y,ende[2] -hoehe_gefaehlle ),dxfattribs={"rotation": 180})
return start, ende
if laenge > asoffset:
start[1] = start[1] - asoffset
start[2] = start[2]
line = Line.new(dxfattribs={"start": start, "end": ende})
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-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 ((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")or (vario_richtung == "Horizontal" and drehung0 == "GUZS" and (mit_horizontal_verbunden == "oben_drehung_0_or_-90" or mit_horizontal_verbunden == "unten_drehung_-180_or_-270"))):
block_es = "200000146_ES-Element_90_rechts"
import_block(block_es,lib_doc,doc)
# block_es = dreh_block(block_es,doc,math.radians(winkel_es))
# esoffset_y = asoffset * math.cos(math.radians(winkel_es))
# esoffset_z = asoffset * math.sin(math.radians(winkel_es))
if vario_richtung == "Auf":
start = (x , y + dy-esoffset,upper_hoehe_gefaehlle )
ende = (x , y - dy ,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_es, (start[0]-x ,start[1]+esoffset-y ,start[2] -hoehe_gefaehlle ),dxfattribs={"rotation": 180})
return start, ende
elif vario_richtung == "Ab":
start = (x , y + dy,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle )
block_vario.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset-y ,ende[2] -hoehe_gefaehlle ))
return start, ende
elif vario_richtung =="Horizontal":
start = (x , y + dy-esoffset_y,upper_hoehe_gefaehlle )
ende = (x , y - dy ,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_es, (start[0]-x ,start[1]+esoffset-y ,start[2] -hoehe_gefaehlle ),dxfattribs={"rotation": 180})
return start, ende
if laenge > esoffset:
ende[1] = ende[1] + esoffset
ende[2] = ende[2]
line = Line.new(dxfattribs={"start": start, "end": ende})
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_gefaehlle)
gefaelle_block.add_entity(copy)
gefaelle_block.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset_y-y ,ende[2] -hoehe_gefaehlle - esoffset_z/2))
return False
else:
msp.add_blockref(block_es,(x,y,lower_hoehe_gefaehlle))
return True
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")or (vario_richtung == "Horizontal" and drehung0 == "UZS" and (mit_horizontal_verbunden == "unten_drehung_0_or_-90" or mit_horizontal_verbunden == "oben_drehung_-180_or_-270"))):
block_as = "200000241_AS-Element_90_rechts"
block_as = "200000217_AS-Element_90_links"
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)
block_vario.add_blockref(block_as,(ende[0]-x ,ende[1]-asoffset -y,ende[2] - hoehe_gefaehlle))
return start, ende
elif vario_richtung == "Ab":
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy ,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
return start, ende
elif vario_richtung =="Horizontal":
start = (x , y + dy ,upper_hoehe_gefaehlle)
ende = (x , y - dy + asoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_as,(ende[0]-x ,ende[1]-asoffset -y,ende[2] - hoehe_gefaehlle))
return start, ende
if laenge > asoffset:
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)
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 (( 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")or (vario_richtung == "Horizontal" and drehung0 == "UZS" and (mit_horizontal_verbunden == "oben_drehung_0_or_-90" or mit_horizontal_verbunden == "unten_drehung_-180_or_-270"))):
block_es = "400102632_ES-Element_90_links"
import_block(block_es,lib_doc,doc)
if vario_richtung == "Auf":
start = (x , y + dy-esoffset ,upper_hoehe_gefaehlle)
ende = (x , y - dy,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_es, (start[0]-x ,start[1]+esoffset -y,start[2] - hoehe_gefaehlle))
return start, ende
elif vario_richtung == "Ab":
start = (x , y + dy ,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset -y,ende[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
return start,ende
elif vario_richtung =="Horizontal":
start = (x , y + dy-esoffset ,upper_hoehe_gefaehlle)
ende = (x , y - dy,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_es, (start[0]-x ,start[1]+esoffset -y,start[2] - hoehe_gefaehlle))
return start, ende
if laenge > esoffset:
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)
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})
return True
def gefaellegerade_erstellung(x, y, doc, lib_doc, upper_hoehe_gefaehlle, lower_hoehe_gefaehlle, hoehe_gefaehlle,richtung2, drehung0, drehung1, laenge, hight_position, blockname,config, block_vario = None,voerder_richtung = None, am_kreisel = None, erster_kreisel_höher = None,y1=None,z1 =None):
#erstellung des blockes falls die gefaelle strecke mit einem kreisel verbunden ist, mehrere variation von selben weil diese nötig sind sobald man die richtigen inserts bekommen
asoffset = float(config.get("ILS 2.0 Gefällestrecke", "asoffset"))
esoffset = float(config.get("ILS 2.0 Gefällestrecke", "esoffset"))
if upper_hoehe_gefaehlle < lower_hoehe_gefaehlle:
middle_hoehe = upper_hoehe_gefaehlle
upper_hoehe_gefaehlle = lower_hoehe_gefaehlle
lower_hoehe_gefaehlle = middle_hoehe
if richtung2!= "DEFAULT" or am_kreisel != None:
if ((blockname not in doc.blocks and drehung0 == "GUZS" and drehung1 == "GUZS" and hight_position == "higher") or
(voerder_richtung == "Auf" and((am_kreisel == 1 and erster_kreisel_höher == False)or (am_kreisel== 2 and erster_kreisel_höher == True)) and drehung0 == "GUZS" and drehung1== "GUZS") or
(voerder_richtung == "Ab"and ((am_kreisel == 1 and erster_kreisel_höher == True)or (am_kreisel== 2 and erster_kreisel_höher == False)) and drehung0 == "GUZS" and drehung1== "GUZS")):
block_es = "200000146_ES-Element_90_rechts"
import_block(block_es,lib_doc,doc)
# block_es = dreh_block(block_es,doc,math.radians(3))
# esoffset_y = esoffset * math.cos(math.radians(3))
# esoffset_z = esoffset * math.sin(math.radians(3))
if am_kreisel == None:
block = doc.blocks.new(name=blockname, base_point=(0,0,0))
halbe_laenge = laenge / 2
dy = halbe_laenge * math.cos(0)
if voerder_richtung == "Auf":
start = (x , y+ dy - esoffset,upper_hoehe_gefaehlle)
ende = (x , y1 ,z1)
block_vario.add_blockref(block_es, (start[0]-x ,start[1]+esoffset-y ,start[2] -hoehe_gefaehlle),dxfattribs={"rotation": 180})
return start,ende
elif(voerder_richtung == "Ab"):
start = (x , y1 ,z1)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset-y ,ende[2] -hoehe_gefaehlle))
return start, ende
start = (x , y + dy,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
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 ))
elif ((blockname not in doc.blocks and drehung0 == "GUZS" and drehung1 == "GUZS") or
(am_kreisel != None and drehung0 == "GUZS" and drehung1 == "GUZS")):
if am_kreisel == None:
block = doc.blocks.new(name=blockname, base_point=(0,0,0))
halbe_laenge = laenge / 2
block_as = "200000241_AS-Element_90_rechts"
import_block(block_as,lib_doc,doc)
block_as = dreh_block(block_es,doc,math.radians(3))
dy = halbe_laenge * math.cos(0)
if voerder_richtung == "Auf":
start = (x , y1 ,z1)
ende = (x , y - dy + asoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_as,(ende[0]-x ,ende[1]-asoffset -y,ende[2] -hoehe_gefaehlle), dxfattribs={"rotation": 180})
return start,ende
elif voerder_richtung == "Ab":
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y1 ,z1)
block_vario.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] -hoehe_gefaehlle))
return start, ende
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy ,lower_hoehe_gefaehlle)
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))
elif ((blockname not in doc.blocks and (drehung0 == "GUZS" and drehung1 == "UZS" and hight_position == "higher"))or
(voerder_richtung == "Auf" and((am_kreisel == 1 and erster_kreisel_höher == False)or (am_kreisel == 2 and erster_kreisel_höher == True))and (drehung0 == "UZS" and drehung1 == "GUZS")) or
(voerder_richtung == "Ab" and((am_kreisel == 1 and erster_kreisel_höher == True) or (am_kreisel ==2 and erster_kreisel_höher ==False))and (drehung0 == "GUZS" and drehung1 == "UZS"))):
block_es = "400102632_ES-Element_90_links"
import_block(block_es,lib_doc,doc)
if am_kreisel == None:
block = doc.blocks.new(name=blockname, base_point=(0,0,0))
halbe_laenge = laenge / 2
dy = halbe_laenge * math.cos(0)
if voerder_richtung == "Auf":
start = (x , y + dy - esoffset,upper_hoehe_gefaehlle)
ende = (x , y1 ,z1)
block_vario.add_blockref(block_es,(start[0]-x ,start[1]+esoffset -y,start[2] - hoehe_gefaehlle))
return start,ende
elif voerder_richtung == "Ab":
start = (x , y1 ,z1)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_es,(ende[0]-x ,ende[1]-esoffset -y,ende[2] - hoehe_gefaehlle), dxfattribs={"rotation": 180})
return start,ende
start = (x , y + dy ,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
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})
elif (blockname not in doc.blocks and (drehung0 == "UZS" and drehung1 == "GUZS" and hight_position == "lower")or
(voerder_richtung == "Auf" and((am_kreisel == 1 and erster_kreisel_höher == True)or (am_kreisel == 2 and erster_kreisel_höher == False))and (drehung0 == "UZS" and drehung1 == "GUZS")) or
(voerder_richtung == "Ab"and ((am_kreisel == 1 and erster_kreisel_höher == False)or (am_kreisel == 2 and erster_kreisel_höher == True))and (drehung0 == "GUZS" and drehung1 == "UZS"))):
block_as = "200000241_AS-Element_90_rechts"
import_block(block_as,lib_doc,doc)
if am_kreisel == None:
block = doc.blocks.new(name=blockname, base_point=(0,0,0))
halbe_laenge = laenge / 2
dy = halbe_laenge * math.cos(0)
if voerder_richtung == "Auf":
start = (x , y1,z1)
ende = (x , y - dy +asoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_as,(ende[0]-x ,ende[1]-asoffset -y,ende[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
return start,ende
elif voerder_richtung == "Ab":
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y1 ,z1)
block_vario.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] - hoehe_gefaehlle))
return start,ende
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy ,lower_hoehe_gefaehlle)
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))
elif ((blockname not in doc.blocks and drehung0 == "UZS" and drehung1 == "UZS" and hight_position == "higher")or
(voerder_richtung == "Auf" and((am_kreisel == 1 and erster_kreisel_höher == False)or (am_kreisel== 2 and erster_kreisel_höher == True)) and drehung0 == "UZS" and drehung1== "UZS")or
(voerder_richtung == "Ab" and((am_kreisel == 1 and erster_kreisel_höher == True)or (am_kreisel== 2 and erster_kreisel_höher == False)) and drehung0 == "UZS" and drehung1== "UZS")):
if am_kreisel == None:
block = doc.blocks.new(name=blockname, base_point=(0,0,0))
halbe_laenge = laenge / 2
block_es = "400102632_ES-Element_90_links"
import_block(block_es,lib_doc,doc)
dy = halbe_laenge * math.cos(0)
if voerder_richtung == "Auf":
start = (x , y + dy - esoffset,upper_hoehe_gefaehlle)
ende = (x , y1,z1)
block_vario.add_blockref(block_es, (start[0]-x ,start[1]+esoffset -y,start[2] - hoehe_gefaehlle))
return start,ende
elif voerder_richtung == "Ab":
start = (x , y1 ,z1)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset -y,ende[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
return start, ende
start = (x , y + dy ,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
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})
elif (((blockname not in doc.blocks and drehung0 == "UZS" and drehung1 == "UZS")or
(am_kreisel!= None and drehung0 == "UZS" and drehung1 == "UZS"))):
block_as = "200000217_AS-Element_90_links"
import_block(block_as,lib_doc,doc)
if am_kreisel == None:
block = doc.blocks.new(name=blockname, base_point=(0,0,0))
halbe_laenge = laenge / 2
dy = halbe_laenge * math.cos(0)
if voerder_richtung == "Auf":
start = (x , y1,z1)
ende = (x , y - dy + asoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_as,(ende[0]-x ,ende[1]-asoffset -y,ende[2] - hoehe_gefaehlle))
return start, ende
elif voerder_richtung == "Ab":
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y1 ,z1)
block_vario.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
return start,ende
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy ,lower_hoehe_gefaehlle)
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})
elif (blockname not in doc.blocks and ((drehung0 == "UZS" and drehung1 == "GUZS" and hight_position== "higher"))or
(voerder_richtung == "Auf"and ((am_kreisel == 1 and erster_kreisel_höher == False) or (am_kreisel ==2 and erster_kreisel_höher ==True))and (drehung0 == "GUZS" and drehung1 == "UZS")) or
(voerder_richtung == "Ab" and((am_kreisel == 1 and erster_kreisel_höher == True)or (am_kreisel == 2 and erster_kreisel_höher == False))and (drehung0 == "UZS" and drehung1 == "GUZS"))):
block_es = "200000146_ES-Element_90_rechts"
import_block(block_es,lib_doc,doc)
if am_kreisel == None:
block = doc.blocks.new(name=blockname, base_point=(0,0,0))
halbe_laenge = laenge / 2
dy = halbe_laenge * math.cos(0)
if voerder_richtung == "Auf":
start = (x , y + dy - esoffset,upper_hoehe_gefaehlle)
ende = (x , y1 ,z1)
block_vario.add_blockref(block_es, (start[0]-x ,start[1]+esoffset -y,start[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
return start, ende
elif voerder_richtung == "Ab":
start = (x , y1,z1)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset -y,ende[2] - hoehe_gefaehlle))
return start,ende
start = (x , y + dy,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
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))
elif (blockname not in doc.blocks and (drehung0 == "GUZS" and drehung1 == "UZS" and hight_position == "lower")or
(voerder_richtung == "Auf"and((am_kreisel == 1 and erster_kreisel_höher == True)or (am_kreisel == 2 and erster_kreisel_höher == False))and (drehung0 == "GUZS" and drehung1 == "UZS")) or
(voerder_richtung == "Ab" and((am_kreisel == 1 and erster_kreisel_höher == False)or (am_kreisel == 2 and erster_kreisel_höher == True))and (drehung0 == "UZS" and drehung1 == "GUZS"))):
block_as = "200000217_AS-Element_90_links"
import_block(block_as,lib_doc,doc)
if am_kreisel == None:
block = doc.blocks.new(name=blockname, base_point=(0,0,0))
halbe_laenge = laenge / 2
dy = halbe_laenge * math.cos(0)
if voerder_richtung == "Auf":
start = (x , y1,z1)
ende = (x , y - dy + asoffset ,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_as,(ende[0]-x ,ende[1]-asoffset -y,ende[2] - hoehe_gefaehlle))
return start, ende
elif voerder_richtung == "Ab":
start = (x , y +dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y1 ,z1)
block_vario.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
return start,ende
start = (x , y +dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy ,lower_hoehe_gefaehlle)
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})
#erstellung von den normalen gefällestrecken
else:
if ((blockname not in doc.blocks and drehung0 == "GUZS" and drehung1 == "GUZS") or (voerder_richtung != None and drehung0 == "GUZS" and drehung1 == "GUZS")):
block_as = "200000241_AS-Element_90_rechts"
import_block(block_as,lib_doc,doc)
block_es = "200000146_ES-Element_90_rechts"
import_block(block_es,lib_doc,doc)
if hight_position != None:
block = doc.blocks.new(name=blockname, base_point=(0,0,0))
halbe_laenge = laenge / 2
dy = halbe_laenge * math.cos(0)
if voerder_richtung == "Auf":
start = (x , y + dy - esoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy + asoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_es,(start[0]-x ,start[1]+esoffset -y,start[2] -hoehe_gefaehlle), dxfattribs={"rotation": 180})
block_vario.add_blockref(block_as, (ende[0]-x ,ende[1]-asoffset-y ,ende[2] -hoehe_gefaehlle), dxfattribs={"rotation": 180})
return start,ende
elif voerder_richtung == "Ab":
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] -hoehe_gefaehlle))
block_vario.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset-y ,ende[2] -hoehe_gefaehlle))
return start, ende
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
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_as = "200000241_AS-Element_90_rechts"
import_block(block_as,lib_doc,doc)
block_es = "200000146_ES-Element_90_rechts"
import_block(block_es,lib_doc,doc)
block.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] -hoehe_gefaehlle))
block.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset-y ,ende[2] -hoehe_gefaehlle))
elif (blockname not in doc.blocks and((drehung0 == "GUZS" and drehung1 == "UZS" and hight_position == "higher")or (drehung0 == "UZS" and drehung1 == "GUZS" and hight_position == "lower")) or
(voerder_richtung == "Auf" and drehung0 == "UZS"and drehung1 == "GUZS") or
(voerder_richtung == "Ab" and drehung0 == "GUZS" and drehung1 == "UZS")) :
block_as = "200000241_AS-Element_90_rechts"
import_block(block_as,lib_doc,doc)
block_es = "400102632_ES-Element_90_links"
import_block(block_es,lib_doc,doc)
if hight_position != None:
block = doc.blocks.new(name=blockname, base_point=(0,0,0))
halbe_laenge = laenge / 2
dy = halbe_laenge * math.cos(0)
if voerder_richtung == "Auf":
start = (x , y + dy - esoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy + asoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_es,(start[0]-x ,start[1]+ esoffset -y,start[2] - hoehe_gefaehlle))
block_vario.add_blockref(block_as, (ende[0]-x ,ende[1]- asoffset-y,ende[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
return start, ende
elif voerder_richtung == "Ab":
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] - hoehe_gefaehlle))
block_vario.add_blockref(block_es, (ende[0]-x ,ende[1]- esoffset-y,ende[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
return start, ende
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
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))
block.add_blockref(block_es, (ende[0]-x ,ende[1]- esoffset-y,ende[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
elif ((blockname not in doc.blocks and drehung0 == "UZS" and drehung1 == "UZS") or (voerder_richtung != None and drehung0 == "UZS" and drehung1 == "UZS")):
block_as = "200000217_AS-Element_90_links"
import_block(block_as,lib_doc,doc)
block_es = "400102632_ES-Element_90_links"
import_block(block_es,lib_doc,doc)
if hight_position !=None:
block = doc.blocks.new(name=blockname, base_point=(0,0,0))
halbe_laenge = laenge / 2
dy = halbe_laenge * math.cos(0)
if voerder_richtung == "Auf":
start = (x , y + dy - esoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy + asoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_es,(start[0]-x ,start[1]+esoffset -y,start[2] - hoehe_gefaehlle))
block_vario.add_blockref(block_as, (ende[0]-x ,ende[1]-asoffset -y,ende[2] - hoehe_gefaehlle))
return start, ende
elif voerder_richtung == "Ab":
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
block_vario.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset -y,ende[2] - hoehe_gefaehlle) ,dxfattribs={"rotation": 180})
return start, ende
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
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})
block.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset -y,ende[2] - hoehe_gefaehlle) ,dxfattribs={"rotation": 180})
elif ((blockname not in doc.blocks and ((drehung0 == "UZS" and drehung1 == "GUZS" and hight_position== "higher")or (drehung0 == "GUZS" and drehung1 == "UZS" and hight_position == "lower")))or
(voerder_richtung == "Auf" and drehung0 == "GUZS" and drehung1 == "UZS") or
(voerder_richtung == "Ab" and drehung0 == "UZS"and drehung1 == "GUZS")) :
block_as = "200000217_AS-Element_90_links"
import_block(block_as,lib_doc,doc)
block_es = "200000146_ES-Element_90_rechts"
import_block(block_es,lib_doc,doc)
if hight_position != None:
block = doc.blocks.new(name=blockname, base_point=(0,0,0))
halbe_laenge = laenge / 2
dy = halbe_laenge * math.cos(0)
if voerder_richtung == "Auf":
start = (x , y + dy - esoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy + asoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_es,(start[0]-x ,start[1]+esoffset -y,start[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
block_vario.add_blockref(block_as, (ende[0]-x ,ende[1]-asoffset -y,ende[2] - hoehe_gefaehlle))
return start,ende
elif voerder_richtung == "Ab":
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
block_vario.add_blockref(block_as,(start[0]-x ,start[1]+asoffset -y,start[2] - hoehe_gefaehlle),dxfattribs={"rotation": 180})
block_vario.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset -y,ende[2] - hoehe_gefaehlle))
return start,ende
start = (x , y + dy - asoffset,upper_hoehe_gefaehlle)
ende = (x , y - dy + esoffset,lower_hoehe_gefaehlle)
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})
block.add_blockref(block_es, (ende[0]-x ,ende[1]-esoffset -y,ende[2] - hoehe_gefaehlle))
def am_kreisel_direct_verbunden(x, y, upper_hoehe_gefaehlle, lower_hoehe_gefaehlle, x0_kreisel, y0_kreisel, richtung_rad0, abstand0, dx, dy, x1_kreisel, y1_kreisel, richtung_rad1, abstand1,kreisel_verbunden= None, richtung0 = None, richtung1 = None, richtung2 = None):
if kreisel_verbunden == None:
kreisel_verbunden = 0
unterschiedlich = False
am_kreisel = 0
halbabstand0 = abstand0 / 2
dx0 = halbabstand0 * math.cos(richtung_rad0)
dy0 = halbabstand0 * math.sin(richtung_rad0)
pos0_0_floor= (math.floor(x0_kreisel + dx0),math.floor( y0_kreisel + dy0))
pos0_1_floor = (math.floor(x0_kreisel- dx0),math.floor( y0_kreisel- dy0))
pos0_0_round= (round(x0_kreisel + dx0),round( y0_kreisel + dy0))
pos0_1_round = (round(x0_kreisel- dx0),round( y0_kreisel- dy0))
if (x1_kreisel != None):
halbabstand1 = abstand1 / 2
dx1 = halbabstand1 * math.cos(richtung_rad1 )
dy1 = halbabstand1 * math.sin(richtung_rad1)
pos1_0_floor = (math.floor(x1_kreisel + dx1), math.floor(y1_kreisel + dy1))
pos1_1_floor = (math.floor(x1_kreisel - dx1), math.floor(y1_kreisel - dy1))
pos1_0_round = (round(x1_kreisel + dx1), round(y1_kreisel + dy1))
pos1_1_round = (round(x1_kreisel - dx1), round(y1_kreisel - dy1))
# berechnung der geraden einmal abgerunden und einmal gerunden zur negirung des offsets
start_floor = (math.floor(x +dx ), math.floor(y + dy ),upper_hoehe_gefaehlle)
ende_floor = (math.floor(x -dx), math.floor(y - dy ) ,lower_hoehe_gefaehlle)
start_round = (round(x +dx ), round(y + dy ),upper_hoehe_gefaehlle)
ende_round= (round(x -dx), round(y - dy ) ,lower_hoehe_gefaehlle)
# verschiebund der endpunkte der gerade in richtung von dem potentiellen Kreisel für den vergleich wieder mit floor und rundung
abstand_fuer_kreis_start_x_floor = start_floor[0] +RADIUS, start_floor[1]
abstand_gegen_kreis_start_x_floor = start_floor[0] -RADIUS, start_floor[1]
abstand_fuer_kreis_start_y_floor = start_floor[0], start_floor[1] + RADIUS
abstand_gegen_kreis_start_y_floor = start_floor[0], start_floor[1] - RADIUS
abstand_fuer_kreis_ende_x_floor= ende_floor[0] + RADIUS, ende_floor[1]
abstand_gegen_kreis_ende_x_floor= ende_floor[0] - RADIUS, ende_floor[1]
abstand_fuer_kreis_ende_y_floor = ende_floor[0] , ende_floor[1] + RADIUS
abstand_gegen_kreis_ende_y_floor = ende_floor[0] , ende_floor[1] - RADIUS
abstand_fuer_kreis_start_x_round= start_round[0] +RADIUS, start_round[1]
abstand_gegen_kreis_start_x_round = start_round[0] -RADIUS, start_round[1]
abstand_fuer_kreis_start_y_round = start_round[0], start_round[1] + RADIUS
abstand_gegen_kreis_start_y_round = start_round[0], start_round[1] - RADIUS
abstand_fuer_kreis_ende_x_round= ende_round[0] + RADIUS, ende_round[1]
abstand_gegen_kreis_ende_x_round= ende_round[0] - RADIUS, ende_round[1]
abstand_fuer_kreis_ende_y_round = ende_round[0] , ende_round[1] + RADIUS
abstand_gegen_kreis_ende_y_round = ende_round[0] , ende_round[1] - RADIUS
if(richtung0 != None and richtung0 != None):
if (richtung0 != richtung1 and kreisel_verbunden ==1):
if(
(abstand_fuer_kreis_start_y_floor == pos0_0_floor) or
(abstand_fuer_kreis_start_y_floor == pos0_1_floor) or
(abstand_gegen_kreis_start_y_floor == pos0_0_floor) or
(abstand_gegen_kreis_start_y_floor == pos0_1_floor) or
(abstand_fuer_kreis_ende_y_floor == pos0_0_floor) or
(abstand_fuer_kreis_ende_y_floor == pos0_1_floor) or
(abstand_gegen_kreis_ende_y_floor == pos0_0_floor) or
(abstand_gegen_kreis_ende_y_floor == pos0_1_floor) or
(abstand_fuer_kreis_start_y_round == pos0_0_round) or
(abstand_fuer_kreis_start_y_round == pos0_1_round) or
(abstand_gegen_kreis_start_y_round == pos0_0_round) or
(abstand_gegen_kreis_start_y_round == pos0_1_round) or
(abstand_fuer_kreis_ende_y_round == pos0_0_round) or
(abstand_fuer_kreis_ende_y_round == pos0_1_round) or
(abstand_gegen_kreis_ende_y_round == pos0_0_round) or
(abstand_gegen_kreis_ende_y_round == pos0_1_round) or
(abstand_fuer_kreis_start_y_floor == pos1_0_floor) or
(abstand_fuer_kreis_start_y_floor == pos1_1_floor) or
(abstand_gegen_kreis_start_y_floor == pos1_0_floor) or
(abstand_gegen_kreis_start_y_floor == pos1_1_floor) or
(abstand_fuer_kreis_ende_y_floor == pos1_0_floor) or
(abstand_fuer_kreis_ende_y_floor == pos1_1_floor) or
(abstand_gegen_kreis_ende_y_floor == pos1_0_floor) or
(abstand_gegen_kreis_ende_y_floor == pos1_1_floor) or
(abstand_fuer_kreis_start_y_round == pos1_0_round) or
(abstand_fuer_kreis_start_y_round == pos1_1_round) or
(abstand_gegen_kreis_start_y_round == pos1_0_round) or
(abstand_gegen_kreis_start_y_round == pos1_1_round) or
(abstand_fuer_kreis_ende_y_round == pos1_0_round) or
(abstand_fuer_kreis_ende_y_round == pos1_1_round) or
(abstand_gegen_kreis_ende_y_round == pos1_0_round) or
(abstand_gegen_kreis_ende_y_round == pos1_1_round)
):
richtung2= "Vertikal"
unterschiedlich = True
else:
richtung2 = "Horinzontal"
unterschiedlich = True
return richtung2, unterschiedlich
return richtung2, unterschiedlich
# vergleich mit einem kreisel von zwei
if( (abstand_fuer_kreis_start_x_floor == pos0_0_floor) or
(abstand_fuer_kreis_start_x_floor == pos0_1_floor) or
(abstand_gegen_kreis_start_x_floor == pos0_0_floor) or
(abstand_gegen_kreis_start_x_floor == pos0_1_floor) or
(abstand_fuer_kreis_ende_x_floor == pos0_0_floor) or
(abstand_fuer_kreis_ende_x_floor == pos0_1_floor) or
(abstand_gegen_kreis_ende_x_floor == pos0_0_floor) or
(abstand_gegen_kreis_ende_x_floor == pos0_1_floor) or
(abstand_fuer_kreis_start_y_floor == pos0_0_floor) or
(abstand_fuer_kreis_start_y_floor == pos0_1_floor) or
(abstand_gegen_kreis_start_y_floor == pos0_0_floor) or
(abstand_gegen_kreis_start_y_floor == pos0_1_floor) or
(abstand_fuer_kreis_ende_y_floor == pos0_0_floor) or
(abstand_fuer_kreis_ende_y_floor == pos0_1_floor) or
(abstand_gegen_kreis_ende_y_floor == pos0_0_floor) or
(abstand_gegen_kreis_ende_y_floor == pos0_1_floor) or
(abstand_fuer_kreis_start_x_round == pos0_0_round ) or
(abstand_fuer_kreis_start_x_round == pos0_1_round) or
(abstand_gegen_kreis_start_x_round == pos0_0_round) or
(abstand_gegen_kreis_start_x_round == pos0_1_round) or
(abstand_fuer_kreis_ende_x_round == pos0_0_round) or
(abstand_fuer_kreis_ende_x_round == pos0_1_round) or
(abstand_gegen_kreis_ende_x_round == pos0_0_round) or
(abstand_gegen_kreis_ende_x_round == pos0_1_round) or
(abstand_fuer_kreis_start_y_round == pos0_0_round) or
(abstand_fuer_kreis_start_y_round == pos0_1_round) or
(abstand_gegen_kreis_start_y_round == pos0_0_round) or
(abstand_gegen_kreis_start_y_round == pos0_1_round) or
(abstand_fuer_kreis_ende_y_round == pos0_0_round) or
(abstand_fuer_kreis_ende_y_round == pos0_1_round) or
(abstand_gegen_kreis_ende_y_round == pos0_0_round) or
(abstand_gegen_kreis_ende_y_round == pos0_1_round)
):
kreisel_verbunden = kreisel_verbunden +1
# setzung auf kreisel 1 für spätere ausrechnung der geraden form
am_kreisel = 1
if (x1_kreisel == None):
return am_kreisel,kreisel_verbunden
if( (abstand_fuer_kreis_start_x_floor == pos1_0_floor )or
(abstand_fuer_kreis_start_x_floor == pos1_1_floor) or
(abstand_gegen_kreis_start_x_floor == pos1_0_floor) or
(abstand_gegen_kreis_start_x_floor == pos1_1_floor) or
(abstand_fuer_kreis_ende_x_floor == pos1_0_floor) or
(abstand_fuer_kreis_ende_x_floor == pos1_1_floor) or
(abstand_gegen_kreis_ende_x_floor == pos1_0_floor) or
(abstand_gegen_kreis_ende_x_floor == pos1_1_floor) or
(abstand_fuer_kreis_start_y_floor == pos1_0_floor ) or
(abstand_fuer_kreis_start_y_floor == pos1_1_floor) or
(abstand_gegen_kreis_start_y_floor == pos1_0_floor) or
(abstand_gegen_kreis_start_y_floor == pos1_1_floor) or
(abstand_fuer_kreis_ende_y_floor == pos1_0_floor ) or
(abstand_fuer_kreis_ende_y_floor == pos1_1_floor) or
(abstand_gegen_kreis_ende_y_floor == pos1_0_floor) or
(abstand_gegen_kreis_ende_y_floor == pos1_1_floor) or
(abstand_fuer_kreis_start_x_round == pos1_0_round ) or
(abstand_fuer_kreis_start_x_round == pos1_1_round) or
(abstand_gegen_kreis_start_x_round == pos1_0_round) or
(abstand_gegen_kreis_start_x_round == pos1_1_round) or
(abstand_fuer_kreis_ende_x_round == pos1_0_round) or
(abstand_fuer_kreis_ende_x_round == pos1_1_round) or
(abstand_gegen_kreis_ende_x_round == pos1_0_round) or
(abstand_gegen_kreis_ende_x_round == pos1_1_round) or
(abstand_fuer_kreis_start_y_round == pos1_0_round) or
(abstand_fuer_kreis_start_y_round == pos1_1_round) or
(abstand_gegen_kreis_start_y_round == pos1_0_round) or
(abstand_gegen_kreis_start_y_round == pos1_1_round) or
(abstand_fuer_kreis_ende_y_round == pos1_0_round) or
(abstand_fuer_kreis_ende_y_round == pos1_1_round) or
(abstand_gegen_kreis_ende_y_round == pos1_0_round) or
(abstand_gegen_kreis_ende_y_round == pos1_1_round)
):
kreisel_verbunden = kreisel_verbunden +1
am_kreisel = 2
return am_kreisel,kreisel_verbunden
def vario_erstellung(msp,merkmale, x, y, doc, lib_doc, config, winkel, hoehe_vario, laenge, block,block_name_links, start, ende,voerder_richtung,winkel_VP_offset_vorne,winkel_VP_offset_hinten ):
# Entnehmen der Motor und Umlenk station um die Gefähle auzurechnen und ob man diese tatsächlich einfügen muss
winkel_motor = int(config.get("Ils 2.0 core winkel","winkel_motor"))
winkel_umlenk = int(config.get("Ils 2.0 core winkel","winkel_umlenk"))
motor_vorhanden = bool(merkmale.get("hatMotor"))
umlenk_vorhanden = bool(merkmale.get("hatUmlenkung"))
if merkmale.get("Winkel_Gefaellestrecke") != None:
gefahellewinkel =float(merkmale.get("Winkel_Gefaellestrecke"))
gefaelle = float(merkmale.get("Laenge_Gefaellestrecke"))
else:
gefahellewinkel = 0.0
gefaelle = 0.0
# Aktueller offset des motors und Umlenkungstation, wird wahrscheinlich später einfach berechnet (sobald man entschieden hat ob wir nur 3 grad neigung erlauben oder nicht)
umlenk_motor_offset = tuple(float(x) for x in(config.get("ILS 2.0 Variofoerderer","Umlenkstation")).split(","))
# Berechnung des Gefälles
if motor_vorhanden == True:
gefaelle = gefaelle - umlenk_motor_offset[0]
if umlenk_vorhanden == True:
gefaelle = gefaelle - umlenk_motor_offset[0]
#Erstellung des Förderes falls er auf ist oder Horizontal da diese gleich aufgebaut werden
if voerder_richtung== "Auf" or voerder_richtung== "Horizontal":
# erstellung des gefälles falls es nicht null ist (also keins angegeben ist oder es durch andere Sachen wie Motor ersetzt wird)
if gefaelle > 0:
# Setzng die hälfte des Gefälles auf beide seiten falls dieser nicht mit einem anderen Förder verbunden ist was durch die abwesenheit eines motors/umlenkung gezeigt wird
halbesgefaelle = gefaelle/2
if motor_vorhanden == True and umlenk_vorhanden == True:
halbesgefaelle = gefaelle/2
gefaelle_ende = ende[0], ende[1] +halbesgefaelle, ende[2] -math.sin(math.radians(gefahellewinkel))* halbesgefaelle
line_ende_gefaelle = Line.new(dxfattribs={"start": ende,"end": gefaelle_ende})
line_ende_gefaelle.dxf.layer = "6-SP"
copy_ende = line_ende_gefaelle.copy()
copy_ende.translate(-x,-y,-hoehe_vario)
block.add_entity(copy_ende)
ende = gefaelle_ende
gefaelle_start = start[0], start[1] -halbesgefaelle, start[2] +math.sin(math.radians(gefahellewinkel)) * halbesgefaelle
line_start_gefaelle = Line.new(dxfattribs={"start": start,"end": gefaelle_start})
line_start_gefaelle.dxf.layer = "6-SP"
copy_start = line_start_gefaelle.copy()
copy_start.translate(-x,-y,-hoehe_vario)
block.add_entity(copy_start)
start = gefaelle_start
elif motor_vorhanden== True:
gefaelle_start = start[0], start[1] -gefaelle, start[2] +math.sin(math.radians(gefahellewinkel)) * gefaelle
line_start_gefaelle = Line.new(dxfattribs={"start": start,"end": gefaelle_start})
line_start_gefaelle.dxf.layer = "6-SP"
copy_start = line_start_gefaelle.copy()
copy_start.translate(-x,-y,-hoehe_vario)
block.add_entity(copy_start)
start = gefaelle_start
elif umlenk_vorhanden== True:
gefaelle_ende = ende[0], ende[1] +gefaelle, ende[2] -math.sin(math.radians(gefahellewinkel))* gefaelle
line_ende_gefaelle = Line.new(dxfattribs={"start": ende,"end": gefaelle_ende})
line_ende_gefaelle.dxf.layer = "6-SP"
copy_ende = line_ende_gefaelle.copy()
copy_ende.translate(-x,-y,-hoehe_vario)
block.add_entity(copy_ende)
ende = gefaelle_ende
# Den Motorstaton und Umlenkstation auf die richtige position in block einfügen falls nötig
block_Vario_Umlenkstation_500mm ="Vario_Umlenkstation_500mm"
block_Vario_Motorstation_500mm = "Vario_Motorstation_500mm"
import_block(block_Vario_Motorstation_500mm, lib_doc, doc)
import_block(block_Vario_Umlenkstation_500mm , lib_doc, doc)
block_Vario_Motorstation_500mm = dreh_block(block_Vario_Motorstation_500mm,doc,math.radians(winkel_motor))
block_Vario_Umlenkstation_500mm = dreh_block( block_Vario_Umlenkstation_500mm, doc,math.radians(winkel_umlenk))
if umlenk_vorhanden == True:
block.add_blockref(block_Vario_Umlenkstation_500mm,(ende[0] -x,ende[1] -y + umlenk_motor_offset[0]/2,ende[2] - hoehe_vario -umlenk_motor_offset[2]/2 ),dxfattribs={"rotation": 90})
ende = (ende[0] ,ende[1] + umlenk_motor_offset[0],ende[2] -umlenk_motor_offset[2])
if motor_vorhanden == True:
block.add_blockref(block_Vario_Motorstation_500mm, (start[0]-x , start[1] - umlenk_motor_offset[0]/2 -y ,start[2] - hoehe_vario +umlenk_motor_offset[2]/2),dxfattribs={"rotation": 90})
start = start[0] , start[1] - umlenk_motor_offset[0],start[2] +umlenk_motor_offset[2]
if voerder_richtung== "Auf":
# Einfügen der 51 grad Bogen und deren notwendigen Werten von den attributen des bogens in den block
winkel_core = int(config.get("Ils 2.0 core winkel","winkel_boegen"))
winkel_plus = int(winkel) + winkel_core
block_Vario_Bogen_auf = (f"Vario_Bogen_auf_{winkel_plus}°")
block_Vario_Bogen_ab = (f"Vario_Bogen_ab_{winkel_plus}°")
auf_attrib =import_block(block_Vario_Bogen_auf, lib_doc, doc)
ab_attrib =import_block(block_Vario_Bogen_ab, lib_doc, doc)
block_Vario_Bogen_auf = dreh_block(block_Vario_Bogen_auf, doc,math.radians(winkel_core))
block_Vario_Bogen_ab = dreh_block(block_Vario_Bogen_ab, doc,math.radians(-winkel))
Vario_Bogen_auf_Delta_SP_0 = list(float(att)for att in re.split(r"[;,]", auf_attrib["DELTA_SP_0"]))
Vario_Bogen_auf_Delta_SP_1 = list(float(att) for att in re.split(r"[;,]", auf_attrib["DELTA_SP_1"]))
Vario_Bogen_ab_Delta_SP_0 = list(float(att) for att in re.split(r"[;,]", ab_attrib["DELTA_SP_0"]))
Vario_Bogen_ab_Delta_SP_1 = list(float(att) for att in re.split(r"[;,]", ab_attrib["DELTA_SP_1"]))
Vario_Bogen_auf_Delta_VP_1 = list(float(att) for att in re.split(r"[;,]", auf_attrib["DELTA_VP_1"]))
Vario_Bogen_ab_Delta_VP_0= list(float(att) for att in re.split(r"[;,]", ab_attrib["DELTA_VP_0"]))
Vario_Bogen_auf_Delta_SP_0 = [Vario_Bogen_auf_Delta_SP_0 [0] * math.cos(math.radians(winkel_core))+ Vario_Bogen_auf_Delta_SP_0[2]* math.sin(math.radians(winkel_core)) ,Vario_Bogen_auf_Delta_SP_0[1],-Vario_Bogen_auf_Delta_SP_0[0] * math.sin(math.radians(winkel_core))+ Vario_Bogen_auf_Delta_SP_0[2] * math.cos(math.radians(winkel_core)) ]
Vario_Bogen_auf_Delta_SP_1 = [Vario_Bogen_auf_Delta_SP_1 [0] * math.cos(math.radians(winkel_core))+ Vario_Bogen_auf_Delta_SP_1[2]* math.sin(math.radians(winkel_core)) ,Vario_Bogen_auf_Delta_SP_1[1],-Vario_Bogen_auf_Delta_SP_1[0] * math.sin(math.radians(winkel_core))+ Vario_Bogen_auf_Delta_SP_1[2] * math.cos(math.radians(winkel_core)) ]
Vario_Bogen_ab_Delta_SP_0 = [Vario_Bogen_ab_Delta_SP_0 [0] * math.cos(math.radians(-winkel))+ Vario_Bogen_ab_Delta_SP_0[2]* math.sin(math.radians(-winkel)) ,Vario_Bogen_ab_Delta_SP_0[1],-Vario_Bogen_ab_Delta_SP_0[0] * math.sin(math.radians(-winkel))+ Vario_Bogen_ab_Delta_SP_0[2] * math.cos(math.radians(-winkel)) ]
Vario_Bogen_ab_Delta_SP_1 =[ Vario_Bogen_ab_Delta_SP_1 [0] * math.cos(math.radians(-winkel))+ Vario_Bogen_ab_Delta_SP_1[2]* math.sin(math.radians(-winkel)) ,Vario_Bogen_ab_Delta_SP_1[1],-Vario_Bogen_ab_Delta_SP_1[0] * math.sin(math.radians(-winkel))+ Vario_Bogen_ab_Delta_SP_1[2] * math.cos(math.radians(-winkel)) ]
Vario_Bogen_auf_Delta_VP_1 = [Vario_Bogen_auf_Delta_VP_1 [0] * math.cos(math.radians(winkel_core))+ Vario_Bogen_auf_Delta_VP_1[2]* math.sin(math.radians(winkel_core)) ,Vario_Bogen_auf_Delta_VP_1[1],-Vario_Bogen_auf_Delta_VP_1[0] * math.sin(math.radians(winkel_core))+ Vario_Bogen_auf_Delta_VP_1[2] * math.cos(math.radians(winkel_core)) ]
Vario_Bogen_ab_Delta_VP_0 = [Vario_Bogen_ab_Delta_VP_0 [0] * math.cos(math.radians(-winkel))+ Vario_Bogen_ab_Delta_VP_0[2]* math.sin(math.radians(-winkel)) ,Vario_Bogen_ab_Delta_VP_0[1],-Vario_Bogen_ab_Delta_VP_0[0] * math.sin(math.radians(-winkel))+ Vario_Bogen_ab_Delta_VP_0[2] * math.cos(math.radians(-winkel)) ]
# negative Zahlen für x und y positive setzen, damit man weniger nachdenken muss (theoretisch ist SP0 x immer negative und SP1 immer positive aber dies vereinfacht die konsistenz der Werte wann ich was addieren oder subtrahieren muss)
for i, wert in enumerate(Vario_Bogen_auf_Delta_SP_0):
if i< 2 and wert < 0:
Vario_Bogen_auf_Delta_SP_0[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_auf_Delta_SP_1):
if i< 2 and wert< 0:
Vario_Bogen_auf_Delta_SP_1[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_ab_Delta_SP_0):
if i< 2 and wert< 0:
Vario_Bogen_ab_Delta_SP_0[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_ab_Delta_SP_1):
if i< 2 and wert< 0:
Vario_Bogen_ab_Delta_SP_1[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_auf_Delta_VP_1):
if i< 2 and wert< 0:
Vario_Bogen_auf_Delta_VP_1[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_ab_Delta_VP_0):
if i< 2 and wert< 0:
Vario_Bogen_ab_Delta_VP_0[i] = abs(wert)
#einfügen des auf blockes und veränderund der ende Punktes dementsprechend und erstellung von endeVP für die VARIO linie
block.add_blockref(block_Vario_Bogen_auf,(ende[0] -x ,ende[1] +Vario_Bogen_auf_Delta_SP_0[0] -y ,ende[2] - Vario_Bogen_auf_Delta_SP_0[2]- hoehe_vario ),dxfattribs={"rotation": 90})
ende_VP = (ende[0] +Vario_Bogen_auf_Delta_VP_1[1], ende[1]+Vario_Bogen_auf_Delta_VP_1[0]+Vario_Bogen_auf_Delta_SP_0[0],ende[2] + Vario_Bogen_auf_Delta_VP_1[2]- Vario_Bogen_auf_Delta_SP_0[2])
ende = (ende[0] ,ende[1] +Vario_Bogen_auf_Delta_SP_1[0] + Vario_Bogen_auf_Delta_SP_0[0] ,ende[2] + Vario_Bogen_auf_Delta_SP_1[2] - Vario_Bogen_auf_Delta_SP_0[2])
#einfügen des auf blockes und veränderund der start Punktes dementsprechend und erstellung von startVP für die VARIO linie
block.add_blockref(block_Vario_Bogen_ab ,(start[0]-x,start[1] - Vario_Bogen_ab_Delta_SP_1[0] -y ,start[2] - hoehe_vario-Vario_Bogen_ab_Delta_SP_1[2]),dxfattribs={"rotation": 90})
start_VP = start[0] +Vario_Bogen_ab_Delta_VP_0[1],start[1]-Vario_Bogen_ab_Delta_VP_0[0] - Vario_Bogen_ab_Delta_SP_1[0] ,start[2]+Vario_Bogen_ab_Delta_VP_0[2] - Vario_Bogen_ab_Delta_SP_1[2]
start = start[0] ,start[1] - Vario_Bogen_ab_Delta_SP_0[0] - Vario_Bogen_ab_Delta_SP_1[0],start[2] - Vario_Bogen_ab_Delta_SP_1[2]+ Vario_Bogen_ab_Delta_SP_0[2]
# Erstellung der VARIO Line
line_VP = Line.new(dxfattribs={"start":start_VP,"end": ende_VP})
line_VP.dxf.layer = "VARIO"
copy_VP = line_VP.copy()
copy_VP.translate(-x,-y,-hoehe_vario)
block.add_entity(copy_VP)
# Erstellung der zwischen Line
line = Line.new(dxfattribs={"start": start, "end": ende})
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_vario)
block.add_entity(copy)
else:
# Einfügen der 3 grad Bogen und deren notwendigen Werten von den attributen des bogens in den block
block_Vario_Bogen_auf_3 = str(config.get("ILS 2.0 Variofoerderer_Bogen_block_namen","bogen_3_auf"))
block_Vario_Bogen_ab_3 = str(config.get("ILS 2.0 Variofoerderer_Bogen_block_namen","bogen_3_ab"))
auf_3_attrib =import_block(block_Vario_Bogen_auf_3, lib_doc, doc)
ab_3_attrib = import_block(block_Vario_Bogen_ab_3, lib_doc, doc)
block_Vario_Bogen_auf_3= dreh_block(block_Vario_Bogen_auf_3, doc,math.radians(3))
block_Vario_Bogen_ab_3 = dreh_block(block_Vario_Bogen_ab_3, doc,math.radians(0))
Vario_Bogen_auf_3_Delta_SP_0 = list(float(att)for att in re.split(r"[;,]", auf_3_attrib["DELTA_SP_0"]))
Vario_Bogen_auf_3_Delta_SP_1 = list(float(att) for att in re.split(r"[;,]", auf_3_attrib["DELTA_SP_1"]))
Vario_Bogen_ab_3_Delta_SP_0 = list(float(att) for att in re.split(r"[;,]", ab_3_attrib["DELTA_SP_0"]))
Vario_Bogen_ab_3_Delta_SP_1 = list(float(att) for att in re.split(r"[;,]", ab_3_attrib["DELTA_SP_1"]))
Vario_Bogen_auf_3_Delta_VP_1 = list(float(att) for att in re.split(r"[;,]", auf_3_attrib["DELTA_VP_1"]))
Vario_Bogen_ab_3_Delta_VP_0= list(float(att) for att in re.split(r"[;,]", ab_3_attrib["DELTA_VP_0"]))
Vario_Bogen_auf_3_Delta_SP_0 = [Vario_Bogen_auf_3_Delta_SP_0 [0] * math.cos(math.radians(3))+ Vario_Bogen_auf_3_Delta_SP_0[2]* math.sin(math.radians(3)) ,Vario_Bogen_auf_3_Delta_SP_0[1],-Vario_Bogen_auf_3_Delta_SP_0[0] * math.sin(math.radians(3))+ Vario_Bogen_auf_3_Delta_SP_0[2] * math.cos(math.radians(3)) ]
Vario_Bogen_auf_3_Delta_SP_1 = [Vario_Bogen_auf_3_Delta_SP_1 [0] * math.cos(math.radians(3))+ Vario_Bogen_auf_3_Delta_SP_1[2]* math.sin(math.radians(3)) ,Vario_Bogen_auf_3_Delta_SP_1[1],-Vario_Bogen_auf_3_Delta_SP_1[0] * math.sin(math.radians(3))+ Vario_Bogen_auf_3_Delta_SP_1[2] * math.cos(math.radians(3)) ]
Vario_Bogen_ab_3_Delta_SP_0 = [Vario_Bogen_ab_3_Delta_SP_0 [0] ,Vario_Bogen_ab_3_Delta_SP_0[1],Vario_Bogen_ab_3_Delta_SP_0[2] ]
Vario_Bogen_ab_3_Delta_SP_1 =[ Vario_Bogen_ab_3_Delta_SP_1 [0] ,Vario_Bogen_ab_3_Delta_SP_1[1],Vario_Bogen_ab_3_Delta_SP_1[2] ]
Vario_Bogen_auf_3_Delta_VP_1 = [Vario_Bogen_auf_3_Delta_VP_1 [0] * math.cos(math.radians(3))+ Vario_Bogen_auf_3_Delta_VP_1[2]* math.sin(math.radians(3)) ,Vario_Bogen_auf_3_Delta_VP_1[1],-Vario_Bogen_auf_3_Delta_VP_1[0] * math.sin(math.radians(3))+ Vario_Bogen_auf_3_Delta_VP_1[2] * math.cos(math.radians(3)) ]
Vario_Bogen_ab_3_Delta_VP_0 = [Vario_Bogen_ab_3_Delta_VP_0 [0],Vario_Bogen_ab_3_Delta_VP_0[1],Vario_Bogen_ab_3_Delta_VP_0[2] ]
# negative Zahlen für x und y positive setzen, damit man weniger nachdenken muss (theoretisch ist SP0 x immer negative und SP1 immer positive aber dies vereinfacht die konsistenz der Werte wann ich was addieren oder subtrahieren muss)
for i, wert in enumerate(Vario_Bogen_auf_3_Delta_SP_0):
if i< 2 and wert < 0:
Vario_Bogen_auf_3_Delta_SP_0[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_auf_3_Delta_SP_1):
if i< 2 and wert< 0:
Vario_Bogen_auf_3_Delta_SP_1[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_ab_3_Delta_SP_0):
if i< 2 and wert< 0:
Vario_Bogen_ab_3_Delta_SP_0[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_ab_3_Delta_SP_1):
if i< 2 and wert< 0:
Vario_Bogen_ab_3_Delta_SP_1[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_auf_3_Delta_VP_1):
if i< 2 and wert< 0:
Vario_Bogen_auf_3_Delta_VP_1[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_ab_3_Delta_VP_0):
if i< 2 and wert< 0:
Vario_Bogen_ab_3_Delta_VP_0[i] = abs(wert)
#einfügen des auf blockes und veränderund der ende Punktes dementsprechend und erstellung von endeVP für die VARIO linie
if motor_vorhanden == True:
block.add_blockref(block_Vario_Bogen_auf_3,(ende[0] -x ,ende[1] +Vario_Bogen_auf_3_Delta_SP_0[0] -y ,ende[2] - Vario_Bogen_auf_3_Delta_SP_0[2]- hoehe_vario ),dxfattribs={"rotation": 90})
ende_VP = (ende[0] +Vario_Bogen_auf_3_Delta_VP_1[1], ende[1]+Vario_Bogen_auf_3_Delta_VP_1[0]+Vario_Bogen_auf_3_Delta_SP_0[0],ende[2] + Vario_Bogen_auf_3_Delta_VP_1[2]- Vario_Bogen_auf_3_Delta_SP_0[2])
ende = (ende[0] ,ende[1] +Vario_Bogen_auf_3_Delta_SP_1[0] + Vario_Bogen_auf_3_Delta_SP_0[0] ,ende[2] + Vario_Bogen_auf_3_Delta_SP_1[2] - Vario_Bogen_auf_3_Delta_SP_0[2])
else:
ende_VP = ende[0] +Vario_Bogen_auf_3_Delta_VP_1[1] ,ende[1] , ende[2]
#einfügen des auf blockes und veränderund der start Punktes dementsprechend und erstellung von startVP für die VARIO linie
if umlenk_vorhanden == True:
block.add_blockref(block_Vario_Bogen_ab_3 ,(start[0]-x,start[1] - Vario_Bogen_ab_3_Delta_SP_1[0] -y ,start[2] - hoehe_vario - Vario_Bogen_ab_3_Delta_SP_1[2]),dxfattribs={"rotation": 90})
start_VP = start[0] +Vario_Bogen_ab_3_Delta_VP_0[1],start[1]-Vario_Bogen_ab_3_Delta_VP_0[0] - Vario_Bogen_ab_3_Delta_SP_1[0] ,start[2]+Vario_Bogen_ab_3_Delta_VP_0[2] - Vario_Bogen_ab_3_Delta_SP_1[2]
start = start[0] ,start[1] - Vario_Bogen_ab_3_Delta_SP_0[0] - Vario_Bogen_ab_3_Delta_SP_1[0],start[2] +Vario_Bogen_ab_3_Delta_SP_0[2] - Vario_Bogen_ab_3_Delta_SP_1[2]
else:
start_VP = start[0] +Vario_Bogen_ab_3_Delta_VP_0[1],start[1] , start[2]
# Erstellung der VARIO Line
line_VP = Line.new(dxfattribs={"start":start_VP,"end": ende_VP})
line_VP.dxf.layer = "VARIO"
copy_VP = line_VP.copy()
copy_VP.translate(-x,-y,-hoehe_vario)
block.add_entity(copy_VP)
# Erstellung der zwischen Line
line = Line.new(dxfattribs={"start": start, "end": ende})
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_vario)
block.add_entity(copy)
elif voerder_richtung == "Ab":
# Setzng die hälfte des Gefälles auf beide seiten falls dieser nicht mit einem anderen Förder verbunden ist was durch die abwesenheit eines motors/umlenkung gezeigt wird
if gefaelle > 0:
if motor_vorhanden == True and umlenk_vorhanden == True:
halbesgefaelle = gefaelle/2
gefaelle_ende = ende[0], ende[1] +halbesgefaelle, ende[2] +math.sin(math.radians(gefahellewinkel))* halbesgefaelle
line_ende_gefaelle = Line.new(dxfattribs={"start": ende,"end": gefaelle_ende})
line_ende_gefaelle.dxf.layer = "6-SP"
copy_ende = line_ende_gefaelle.copy()
copy_ende.translate(-x,-y,-hoehe_vario)
block.add_entity(copy_ende)
ende = gefaelle_ende
gefaelle_start = start[0], start[1] -halbesgefaelle, start[2] -math.sin(math.radians(gefahellewinkel)) * halbesgefaelle
line_start_gefaelle = Line.new(dxfattribs={"start": start,"end": gefaelle_start})
line_start_gefaelle.dxf.layer = "6-SP"
copy_start = line_start_gefaelle.copy()
copy_start.translate(-x,-y,-hoehe_vario)
block.add_entity(copy_start)
start = gefaelle_start
elif motor_vorhanden == True:
gefaelle_ende = ende[0], ende[1] +gefaelle, ende[2] +math.sin(math.radians(gefahellewinkel))* gefaelle
line_ende_gefaelle = Line.new(dxfattribs={"start": ende,"end": gefaelle_ende})
line_ende_gefaelle.dxf.layer = "6-SP"
copy_ende = line_ende_gefaelle.copy()
copy_ende.translate(-x,-y,-hoehe_vario)
block.add_entity(copy_ende)
ende = gefaelle_ende
elif umlenk_vorhanden == True:
gefaelle_start = start[0], start[1] -gefaelle, start[2] -math.sin(math.radians(gefahellewinkel)) * gefaelle
line_start_gefaelle = Line.new(dxfattribs={"start": start,"end": gefaelle_start})
line_start_gefaelle.dxf.layer = "6-SP"
copy_start = line_start_gefaelle.copy()
copy_start.translate(-x,-y,-hoehe_vario)
block.add_entity(copy_start)
start = gefaelle_start
# Importieren und setzen der UMlenkungstation oder Motorstation falls nötig
block_Vario_Umlenkstation_500mm ="Vario_Umlenkstation_500mm"
block_Vario_Motorstation_500mm = "Vario_Motorstation_500mm"
import_block( block_Vario_Motorstation_500mm, lib_doc, doc)
import_block( block_Vario_Umlenkstation_500mm , lib_doc, doc)
block_Vario_Motorstation_500mm = dreh_block( block_Vario_Motorstation_500mm, doc,math.radians(winkel_motor))
block_Vario_Umlenkstation_500mm = dreh_block( block_Vario_Umlenkstation_500mm , doc,math.radians(winkel_umlenk))
if umlenk_vorhanden == True:
block.add_blockref(block_Vario_Umlenkstation_500mm,(start[0] -x,start[1] -y - umlenk_motor_offset[0]/2, start[2] - hoehe_vario -umlenk_motor_offset[2]/2 ),dxfattribs={"rotation": 270})
start_Umlenkstation_VP = start[0] - 66.5, start[1] -500 *math.cos(math.radians(-winkel_umlenk))+ math.sin(math.radians(-winkel_umlenk))* -45,start[2] + math.sin(math.radians(-winkel_umlenk))*500+ math.cos(math.radians(-winkel_umlenk))*-45
start = (start[0] ,start[1] - umlenk_motor_offset[0],start[2] -umlenk_motor_offset[2])
elif winkel == 3:
start_Umlenkstation_VP = start[0] - 66.5, start[1]+ winkel_VP_offset_vorne[0],start[2] -winkel_VP_offset_hinten[2]
if motor_vorhanden == True:
block.add_blockref(block_Vario_Motorstation_500mm, (ende[0]-x , ende[1] + umlenk_motor_offset[0]/2 -y ,ende[2] - hoehe_vario +umlenk_motor_offset[2]/2),dxfattribs={"rotation": 270})
ende_Motor_VP = ende[0] - 66.5, ende[1] +500 *math.cos(math.radians(-winkel_motor))+ math.sin(math.radians(-winkel_motor))* -45,ende[2] - math.sin(math.radians(-winkel_motor))*500+ math.cos(math.radians(-winkel_motor))*-45
ende = ende[0] , ende[1] + umlenk_motor_offset[0],ende[2] +umlenk_motor_offset[2]
elif winkel == 3:
ende_Motor_VP = ende[0] - 66.5, ende[1]+ winkel_VP_offset_hinten[0] ,ende[2] - winkel_VP_offset_vorne[2]
if winkel != 3:
winkel_core = int(config.get("Ils 2.0 core winkel","winkel_boegen"))
winkel_minus = int(winkel) - winkel_core
block_Vario_Bogen_auf = (f"Vario_Bogen_auf_{winkel_minus}°")
block_Vario_Bogen_ab = (f"Vario_Bogen_ab_{winkel_minus}°")
ab_attrib =import_block( block_Vario_Bogen_ab , lib_doc, doc)
auf_attrib =import_block( block_Vario_Bogen_auf, lib_doc, doc)
block_Vario_Bogen_ab = dreh_block( block_Vario_Bogen_ab, doc, math.radians(winkel_core))
block_Vario_Bogen_auf= dreh_block( block_Vario_Bogen_auf, doc, math.radians(winkel))
Vario_Bogen_auf_Delta_SP_0 = list(float(att)for att in re.split(r"[;,]", auf_attrib["DELTA_SP_0"]))
Vario_Bogen_auf_Delta_SP_1 = list(float(att) for att in re.split(r"[;,]", auf_attrib["DELTA_SP_1"]))
Vario_Bogen_ab_Delta_SP_0 = list(float(att) for att in re.split(r"[;,]", ab_attrib["DELTA_SP_0"]))
Vario_Bogen_ab_Delta_SP_1 = list(float(att) for att in re.split(r"[;,]", ab_attrib["DELTA_SP_1"]))
Vario_Bogen_auf_Delta_VP_0 = list(float(att) for att in re.split(r"[;,]", auf_attrib["DELTA_VP_0"]))
Vario_Bogen_ab_Delta_VP_1= list(float(att) for att in re.split(r"[;,]", ab_attrib["DELTA_VP_1"]))
Vario_Bogen_auf_Delta_SP_0 = [Vario_Bogen_auf_Delta_SP_0 [0] * math.cos(math.radians(winkel))+ Vario_Bogen_auf_Delta_SP_0[2]* math.sin(math.radians(winkel)) ,Vario_Bogen_auf_Delta_SP_0[1],-Vario_Bogen_auf_Delta_SP_0[0] * math.sin(math.radians(winkel))+ Vario_Bogen_auf_Delta_SP_0[2] * math.cos(math.radians(winkel)) ]
Vario_Bogen_auf_Delta_SP_1 = [Vario_Bogen_auf_Delta_SP_1 [0] * math.cos(math.radians(winkel))+ Vario_Bogen_auf_Delta_SP_1[2]* math.sin(math.radians(winkel)) ,Vario_Bogen_auf_Delta_SP_1[1],-Vario_Bogen_auf_Delta_SP_1[0] * math.sin(math.radians(winkel))+ Vario_Bogen_auf_Delta_SP_1[2] * math.cos(math.radians(winkel)) ]
Vario_Bogen_ab_Delta_SP_0 = [Vario_Bogen_ab_Delta_SP_0 [0] * math.cos(math.radians(winkel_core))+ Vario_Bogen_ab_Delta_SP_0[2]* math.sin(math.radians(winkel_core)) ,Vario_Bogen_ab_Delta_SP_0[1],-Vario_Bogen_ab_Delta_SP_0[0] * math.sin(math.radians(3))+ Vario_Bogen_ab_Delta_SP_0[2] * math.cos(math.radians(winkel_core)) ]
Vario_Bogen_ab_Delta_SP_1 =[ Vario_Bogen_ab_Delta_SP_1 [0] * math.cos(math.radians(winkel_core))+ Vario_Bogen_ab_Delta_SP_1[2]* math.sin(math.radians(winkel_core)) ,Vario_Bogen_ab_Delta_SP_1[1],-Vario_Bogen_ab_Delta_SP_1[0] * math.sin(math.radians(3))+ Vario_Bogen_ab_Delta_SP_1[2] * math.cos(math.radians(winkel_core)) ]
Vario_Bogen_auf_Delta_VP_0 = [Vario_Bogen_auf_Delta_VP_0 [0] * math.cos(math.radians(winkel))+ Vario_Bogen_auf_Delta_VP_0[2]* math.sin(math.radians(winkel)) ,Vario_Bogen_auf_Delta_VP_0[1],-Vario_Bogen_auf_Delta_VP_0[0] * math.sin(math.radians(winkel))+ Vario_Bogen_auf_Delta_VP_0[2] * math.cos(math.radians(winkel)) ]
Vario_Bogen_ab_Delta_VP_1 = [Vario_Bogen_ab_Delta_VP_1 [0] * math.cos(math.radians(winkel_core))+ Vario_Bogen_ab_Delta_VP_1[2]* math.sin(math.radians(winkel_core)) ,Vario_Bogen_ab_Delta_VP_1[1],-Vario_Bogen_ab_Delta_VP_1[0] * math.sin(math.radians(3))+ Vario_Bogen_ab_Delta_VP_1[2] * math.cos(math.radians(winkel_core)) ]
# negative Zahlen für x und y positive setzen, damit man weniger nachdenken muss (theoretisch ist SP0 x immer negative und SP1 immer positive aber dies vereinfacht die konsistenz der Werte wann ich was addieren oder subtrahieren muss)
for i, wert in enumerate(Vario_Bogen_auf_Delta_SP_0):
if i< 2 and wert < 0:
Vario_Bogen_auf_Delta_SP_0[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_auf_Delta_SP_1):
if i< 2 and wert< 0:
Vario_Bogen_auf_Delta_SP_1[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_ab_Delta_SP_0):
if i< 2 and wert< 0:
Vario_Bogen_ab_Delta_SP_0[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_ab_Delta_SP_1):
if i< 2 and wert< 0:
Vario_Bogen_ab_Delta_SP_1[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_auf_Delta_VP_0):
if i< 2 and wert< 0:
Vario_Bogen_auf_Delta_VP_0[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_ab_Delta_VP_1):
if i< 2 and wert< 0:
Vario_Bogen_ab_Delta_VP_1[i] = abs(wert)
#einfügen des auf blockes und veränderund der start Punktes dementsprechend und erstellung von startVP für die VARIO linie
block.add_blockref(block_Vario_Bogen_ab, (start[0]-x,start[1]-y- Vario_Bogen_ab_Delta_SP_0[0], start[2]- hoehe_vario- Vario_Bogen_ab_Delta_SP_0[2]),dxfattribs={"rotation": 270})
start_VP = start[0] -Vario_Bogen_ab_Delta_VP_1[1],start[1]- Vario_Bogen_ab_Delta_VP_1[0]- Vario_Bogen_ab_Delta_SP_0[0] ,start[2]+Vario_Bogen_ab_Delta_VP_1[2]-Vario_Bogen_ab_Delta_SP_0[2]
start =(start[0], start[1]- Vario_Bogen_ab_Delta_SP_0[0]- Vario_Bogen_ab_Delta_SP_1[0],start[2]-Vario_Bogen_ab_Delta_SP_0[2]+Vario_Bogen_ab_Delta_SP_1[2])
#einfügen des auf blockes und veränderund der ende Punktes dementsprechend und erstellung von endeVP für die VARIO linie
block.add_blockref(block_Vario_Bogen_auf, (ende[0]-x,ende[1]-y+ Vario_Bogen_auf_Delta_SP_1[0],ende[2]-hoehe_vario -Vario_Bogen_auf_Delta_SP_1[2]),dxfattribs={"rotation": 270})
ende_VP = (ende[0] -Vario_Bogen_auf_Delta_VP_0[1], ende[1] + Vario_Bogen_auf_Delta_VP_0[0]+ Vario_Bogen_auf_Delta_SP_1[0],ende[2]+ Vario_Bogen_auf_Delta_VP_0[2]- Vario_Bogen_auf_Delta_SP_1[2])
ende = (ende[0],ende[1]+ Vario_Bogen_auf_Delta_SP_1[0]+ Vario_Bogen_auf_Delta_SP_0[0],ende[2]- Vario_Bogen_auf_Delta_SP_1[2]+ Vario_Bogen_auf_Delta_SP_0[2])
# Erstellung der VARIO Line
line_VP = Line.new(dxfattribs={"start":start_VP,"end": ende_VP})
line_VP.dxf.layer = "VARIO"
copy_VP = line_VP.copy()
copy_VP.translate(-x,-y,-hoehe_vario)
block.add_entity(copy_VP)
# Erstellung der zwischen Line
line = Line.new(dxfattribs={"start":start,"end":ende })
line.dxf.layer = "6-SP"
copy = line.copy()
copy.translate(-x,-y,-hoehe_vario)
block.add_entity(copy)
elif winkel == 3:
# Nur erstellung der zwischen und Vario linie weil der Bogen hier nicht nötig ist
line_VP = Line.new(dxfattribs={"start": start_Umlenkstation_VP,"end": ende_Motor_VP})
line_VP.dxf.layer = "VARIO"
copy_VP = line_VP.copy()
copy_VP.translate(-x,-y,-hoehe_vario)
block.add_entity(copy_VP)
line = Line.new(dxfattribs={"start": start, "end": ende})
line.dxf.layer = "6-SP"
copy= line.copy()
copy.translate(-x,-y,-hoehe_vario)
block.add_entity(copy)
# Erstellung einer Spiegelung an der y achse (hier wird es ausgeführt durch -x) für die erstellung des Förderers mit den vario stationen links
matrix = Matrix44.scale(-1,1,1)
block_links = doc.blocks.new(block_name_links, base_point=(0,0,0))
#spiegelung aller elemente außer es und as elemente falls diese vorhanden sind um die logik wie die platziert werden nicht zu zerstören
for entity in block:
clone= entity.copy()
if entity.dxftype() == "INSERT":
if (entity.dxf.name == "400102632_ES-Element_90_links" or entity.dxf.name == "200000146_ES-Element_90_rechts" or
entity.dxf.name == "200000241_AS-Element_90_rechts" or entity.dxf.name == "200000217_AS-Element_90_links"
):
block_links.add_entity(clone)
else:
clone.transform(matrix)
block_links.add_entity(clone)
else:
clone.transform(matrix)
block_links.add_entity(clone)
def get_layer(doc, lib_doc, blockname):
if blockname in lib_doc.blocks:
src = lib_doc.blocks[blockname]
else:
src = doc.blocks[blockname]
try:
used_layer_names = {e.dxf.layer for e in src if hasattr(e.dxf, "layer")}
for layer_name in used_layer_names:
if layer_name and layer_name not in doc.layers:
try:
src_layer = lib_doc.layers.get(layer_name)
doc.layers.add(
name=layer_name,
color=getattr(src_layer.dxf, "color", None),
linetype=getattr(src_layer.dxf, "linetype", None),
lineweight=getattr(src_layer.dxf, "lineweight", None),
)
except Exception:
# Fallback: Layer mit Standardwerten anlegen
doc.layers.add(name=layer_name)
except Exception:
pass
layer_counts = {}
for e in src:
ln = getattr(e.dxf, "layer", None)
if not ln:
continue
if ln != "BOUNDING_BOX":
layer_counts[ln] = layer_counts.get(ln, 0) + 1
if layer_counts:
blockref_layer = max(layer_counts.items(), key=lambda kv: kv[1])[0]
return blockref_layer
def normalize_func_name(name):
return (
name.replace('ä', 'ae')
.replace('ö', 'oe')
.replace('ü', 'ue')
.replace('ß', 'ss')
.replace(' ', '_')
.replace('.', '_')
.replace('-', '_')
.lower()
)
def get_libfile_cfg(teileart, cfg_path):
"""Liest den Bibliotheksdateinamen für eine TeileArt aus der allgemein.cfg."""
parser = configparser.ConfigParser()
with open(cfg_path, encoding='utf-8') as f:
parser.read_file(f)
# Teileart kann z.B. "ILS 2.0 Kreisel" sein, wir nehmen den ersten Teil vor erstem Leerzeichen oder Punkt
# oder suchen iterativ nach Sektionen, die im Teileart-Namen vorkommen
for section in parser.sections():
if section in teileart:
return parser.get(section, "libfile", fallback=None)
return None
def get_rotations_of_strecken(csv_path:Path) -> dict:
geraden = []
kreisel =[]
strecken_nachbarn = []
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:
reader = csv.DictReader(fh, delimiter=';')
for row in reader:
bezeichner = row["TeileArt"].strip()
if bezeichner == "ILS 2.0 Gefällestrecke":
Id = row["TeileId"].strip()
NachbarIds = row["NachbarIds"].strip()
geraden.append({"Id": Id, "NachbarIds": NachbarIds})
if bezeichner == "ILS 2.0 Kreisel" or bezeichner == "ILS 2.0 Kreisel mit Pin":
Id = row["TeileId"].strip()
planquadrat = row["Planquadrat"]
x, y = extract_coords(planquadrat)
merkmale = parse_merkmale(row.get("Merkmale", ""))
drehung = merkmale.get("Drehrichtung")
rotation = merkmale.get("Drehung")
hight = float(merkmale.get("Höhe in m")) *1000
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})
if bezeichner =="ILS 2.0 VarioFoerderer":
Id = row["TeileId"].strip()
NachbarIds = row["NachbarIds"].strip()
merkmale = parse_merkmale(row.get("Merkmale", ""))
winkel = merkmale.get("Winkel")
h0 = float(merkmale.get("Höhe Anfang")) * 1000
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")
tefkurve = merkmale.get("AntriebNebenStrecke")
angetriebene_kurve.append({"Id": Id,"H0": h0,"H1":h1,"kurvenrichtung":kurvenrichtung,"Tefkurve": tefkurve})
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")
eintrag["Tefkurve"] = foerderer.get("Tefkurve")
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")
eintrag["Tefkurve_1"] = foerderer.get("Tefkurve")
for kreis in kreisel:
if kreis["Id"] in gerade["NachbarIds"]:
if anweisungen == 0:
eintrag["Drehung0"] = kreis.get("drehung")
eintrag["Hoehe0"] = kreis.get("höhe")
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")
eintrag["Hoehe1"] = kreis.get("höhe")
eintrag["x1"] = kreis.get("x")
eintrag["y1"] = kreis.get("y")
eintrag["rotation1"] = kreis.get("rotation")
eintrag["abstand1"] = kreis.get("abstand")
break
if(gerade.get("Winkel") != None ):
for vario_gerade in geraden:
if vario_gerade["Id"] in gerade["NachbarIds"] and vario_gerade.get("Winkel") != None:
if geraden_anweisung == 0:
eintrag["Winkel"] = vario_gerade.get("Winkel")
eintrag["h0"] = vario_gerade.get("h0")
eintrag["h1"] = vario_gerade.get("h1")
eintrag["Foerderrichtung"] = vario_gerade.get("Foerderrichtung")
geraden_anweisung =1
elif geraden_anweisung == 1:
eintrag["Winkel_2"] = vario_gerade.get("Winkel")
eintrag["h0_2"] = vario_gerade.get("h0")
eintrag["h1_2"] = vario_gerade.get("h1")
eintrag["Foerderrichtung_2"] = vario_gerade.get("Foerderrichtung")
break
strecken_nachbarn.append(eintrag)
return strecken_nachbarn
# --------------------------------------------------------- Hauptfunktion
def main(csv_path: Path, lib_path: Path, cfg_path: Path, allgemein_cfg_path: Path,
output_path: Path, output_path_jason: Path, verbose=False, logger=None ):
data_dir = check_environment_var("PROJECT_DATA")
# Bibliothek nur laden, wenn Datei existiert
check_dxflibrary_path(lib_path, verbose, logger)
parser_cfg_path = configparser.ConfigParser()
try:
with open(cfg_path, encoding='utf-8') as f:
parser_cfg_path.read_file(f)
except Exception as e:
msg = f"Fehler beim Lesen der Config-Datei {cfg_path}: {e}"
# Neue Ziel­zeichnung (DXF R2018)
config =parser_cfg_path
parser_allgemein_path = configparser.ConfigParser()
try:
with open(allgemein_cfg_path, encoding='utf-8') as f:
parser_allgemein_path.read_file(f)
except Exception as e:
msg = f"Fehler beim Lesen der Config-Datei {cfg_path}: {e}"
# Neue Ziel­zeichnung (DXF R2018)
config_allgemein =parser_allgemein_path
doc = ezdxf.new(dxfversion="R2018", setup=True)
doc.units = units.M
doc.header['$INSUNITS'] = 4 # Millimeter
msp = doc.modelspace()
# Höhe bestimmen für Koordinaten-Transformation
try:
height = berechne_hoehe(csv_path, logger=logger)
except Exception as e:
msg = f"Fehler bei der Höhenberechnung: {e}"
if logger:
logger.error(msg)
else:
print(msg)
sys.exit(1)
blocklib_dir = data_dir / "block_libraries"
lib_docs = dict()
# gibt zu jeder ShapeId einer Gefällestrecke zurück, ob sich der jeweilige Kreisel im UZ oder GUZ dreht
# rot_of_gf["shape_3ae53a7b-efb8-f66b-eadc-20b99f949ef1"] = ('UZ', 'GUZ')
strecken_nachbarn = get_rotations_of_strecken(csv_path)
# Verarbeitung der Blöcke
with csv_path.open(newline="", encoding="utf-8") as fh:
reader = csv.DictReader(fh, delimiter=';')
for row in reader:
bezeichner = row["Bezeichnung"].strip()
teileart = row["TeileArt"].strip()
teileid = row["TeileId"].strip()
planquadrat = row["Planquadrat"]
merkmale = parse_merkmale(row.get("Merkmale", ""))
merkmale["bezeichner"] = bezeichner
try:
x_screen, y_screen = extract_coords(planquadrat)
x, y = transform_coords(x_screen, y_screen, height)
except Exception as e:
msg = f"[WARN] {teileid}: {e}"
if logger:
logger.warning(msg)
else:
print(msg)
continue
# Bibliotheksdatei bestimmen
libfile = get_libfile_cfg(teileart, allgemein_cfg_path)
if libfile:
lib_path = blocklib_dir / libfile
else:
lib_path = default_lib_path
# Bibliothek laden (mit Cache)
lib_doc = None
if lib_path in lib_docs:
lib_doc = lib_docs[lib_path]
elif lib_path.exists():
try:
lib_doc = ezdxf.readfile(lib_path)
lib_docs[lib_path] = lib_doc
if verbose:
print(f"[INFO] Bibliothek geladen: {lib_path}")
except Exception as e:
print(f"[WARN] Fehler beim Lesen der Bibliothek '{lib_path}': {e}")
else:
print(f"[INFO] Keine Bibliothek gefunden unter {lib_path}. Komplexe Formen werden übersprungen.")
# Funktions-Dispatch: handle_<teileart> (mit _ statt Leerzeichen und Punkten, alles klein)
func_name = f'handle_{normalize_func_name(teileart)}'
handler = globals().get(func_name)
symbols = get_shape_cfg(teileart, cfg_path, logger=logger)
# Mapping für Omniflo-Typen
if func_name.startswith('handle_omniflo') or func_name.startswith('handle_tef'):
handler = globals().get('handle_omniflo')
if handler:
handler(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn, config,config_allgemein)
else:
msg = f"[WARN] Keine Routine für TeileArt '{teileart}'. Überspringe '{teileid}'."
if logger:
logger.warning(msg)
else:
print(msg)
for insert in msp.query("INSERT"):
basepoint = insert.dxf.insert
# data = []
# for e in msp.query("INSERT"):
# ents = list(e.virtual_entities())
# # Bounding Box des Blocks berechnen
# bb = bbox.extents(ents)
# 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
# })
# with open(output_path_jason, "w", encoding="utf-8") as datei:
# json.dump(data, datei, ensure_ascii=False, indent=4)
# for insert in msp.query("INSERT"):
# name = insert.dxf.name # Name des referenzierten Blocks
# position = insert.dxf.insert
# if name == "834372115":
# symbol_att = import_block("834372115_symbol",lib_doc,doc)
# block = doc.blocks["834372115_symbol"]
# for e in block:
# if e.dxftype() != "INSERT":
# block.delete_entity(e)
# att =msp.add_blockref("834372115_symbol",(position[0],position[1],position[2])) # Einfügepunkt (x, y, z)
# rotation = insert.dxf.rotation
# layer = insert.dxf.layer
doc.saveas(output_path)
if logger:
logger.info(f"[DONE] DXF gespeichert unter: {output_path}")
else:
print(f"[DONE] DXF gespeichert unter: {output_path}")
# def change_layer(doc, insert):
# src = doc.blocks[insert.dxf.name]
# for e in src:
# e.dxf.layer = "Motor"
# if e.dxftype() == "INSERT":
# change_layer(doc,e)
def check_dxflibrary_path(lib_path, verbose, logger):
lib_doc = None
if lib_path.exists():
try:
lib_doc = ezdxf.readfile(lib_path)
if verbose:
logger.info(f"[INFO] Bibliothek geladen: {lib_path}") if logger else print(f"[INFO] Bibliothek geladen: {lib_path}")
except Exception as e:
msg = f"Fehler beim Lesen der Bibliothek '{lib_path}': {e}"
if logger:
logger.error(msg)
else:
print(msg)
sys.exit(1)
else:
msg = f"[INFO] Keine Bibliothek gefunden unter {lib_path}."
if logger:
logger.error(msg)
else:
print(msg)
sys.exit(1)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Plaziert Anlagenkomponenten aus RuleDesigner CSV.")
parser.add_argument("-f", "--file", required=True, help="CSV-Datei (Name oder Pfad)", metavar="input.csv")
parser.add_argument("-c", "--config", help="CFG mit einfachen Formen", metavar="shapes.cfg")
parser.add_argument("-l", "--lib", help="DXF-Bibliothek mit Blöcken", metavar="bibliothek.dxf")
parser.add_argument("-o", "--output", help="Ziel-DXF (Standard: PROJECT_WORK/anlage.dxf)", metavar="anlage.dxf")
parser.add_argument("-v", "--verbose", action="store_true", help="mehr Ausgaben anzeigen")
args = parser.parse_args()
# Verzeichnisse aus Umgebungs­variablen
log_dir = check_environment_var("PROJECT_LOG")
data_dir = check_environment_var("PROJECT_DATA")
work_dir = check_environment_var("PROJECT_WORK")
config_dir = check_environment_var("PROJECT_CFG")
logger = setup_logger(log_dir, name='plant2dxf')
logger.info("=== plant2dxf Verarbeitung gestartet ===")
# CSVPfad: nur Dateiname → im WORKOrdner suchen
if os.sep not in args.file and "/" not in args.file:
csv_path = work_dir / args.file
else:
csv_path = Path(args.file)
cfg_path = Path(args.config) if args.config else config_dir / "shapes.cfg"
allgemein_cfg_path = config_dir / "allgemein.cfg"
default_lib_path = Path(args.lib) if args.lib else data_dir / "blocks.dxf"
output_path = Path(args.output) if args.output else (work_dir / f"{csv_path.stem}.dxf")
output_path_jason = Path(args.output) if args.output else (work_dir / f"{csv_path.stem}.jason")
main(csv_path, default_lib_path, cfg_path,allgemein_cfg_path, output_path,output_path_jason, verbose=args.verbose, logger=logger)
logger.info("=== plant2dxf Verarbeitung abgeschlossen ===")