# -*- coding: utf-8 -*- from ezdxf.entities import Line import math from pydantic import BaseModel, Field, field_validator from typing import Optional import plant2dxf from ezdxf.math import Matrix44 import re import block_methoden class VarioFoerderer(BaseModel): teileid: str x: float = Field(description="X-Koordinate des Foerder-Zentrums") y: float = Field(description="Y-Koordinate des Foerder-Zentrums") laenge: float = Field(description="Länge des Förderers") winkel: float = Field(description="Winkel des Färderers") h0: float = Field(description="Höhe Anfang in Merkmale") h1: float = Field(description="Höhe Ende in Merkmale") hat_motor: bool = Field(description="Überprüft ob der Vörderer ein Motor hat") hat_umlenk: bool = Field( description="Überprüft ob der Vörderer eine Umlenkstation hat" ) drehung: float = Field(default=0.0, description="Drehung/Winkel in Grad") foerderer_richtung: str = Field(description="In welche richtung geförderd wird") gefaelle_laenge: Optional[float] = Field( default=0.0, description="Länge der zusätzlichen Gefälle Strecke falls vorhanden", ) gefaelle_winkel: Optional[float] = Field( default=0.0, description="Winkel der Gefällestrecke, falls diese Vorhanden ist" ) anzahl_scanner: int = Field(default=0, description="Anzahl der Scanner") anzahl_separatoren: int = Field(default=0, description="Anzahl der Separatoren") @property def hight_zwischen(self): return (self.h0 + self.h1) / 2 @classmethod def from_merkmale( cls, teileid: str, x: float, y: float, merkmale: dict ) -> "VarioFoerderer": h0 = float(merkmale.get("Höhe Anfang")) * 1000 h1 = float(merkmale.get("Höhe Ende")) * 1000 laenge = float(merkmale.get("Länge in Meter")) * 1000 gefaelle_laenge = merkmale.get("Laenge_Gefaellestrecke") gefaelle_winkel = merkmale.get("Winkel_Gefaellestrecke") if gefaelle_laenge == None: gefaelle_laenge = 0.0 gefaelle_winkel = 0.0 else: gefaelle_laenge = float(gefaelle_laenge) gefaelle_winkel = float(gefaelle_winkel) return cls( teileid=teileid, x=x, y=y, laenge=laenge, winkel=float(merkmale.get("Winkel")), h0=h0, h1=h1, hat_motor=bool(merkmale.get("Motorstation_hinten")), hat_umlenk=bool(merkmale.get("Spannstation_vorn")), drehung=float(merkmale.get("Drehung")), foerderer_richtung=merkmale.get("Förderrichtung"), gefaelle_laenge=gefaelle_laenge, gefaelle_winkel=gefaelle_winkel, anzahl_scanner=int(merkmale.get("Anzahl der Scanner")), anzahl_separatoren=int(merkmale.get("Anzahl der Separatoren")), ) def get_offset_of_Vario_line(doc, lib_doc, foerderer, gefaellestrecke_vario): """Schaut nach was für ein Zusatz oder nicht man braucht falls es kein motor/umlenk station hat und kein bogen""" winkel_VP_offset_vorne = None winkel_VP_offset_hinten = None voerder_richtung = foerderer.foerderer_richtung winkel = int(foerderer.winkel) rotation = foerderer.drehung upper_hoehe_vario = foerderer.h1 lower_hoehe_vario = foerderer.h0 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 and voerder_richtung != "Horizontal" ): if gefaellestrecke_vario.get("Foerderrichtung") == "Auf": # 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_auf_{winkel_vorne_plusbogen}°" att_vorne = block_methoden.import_block(blockname, lib_doc, doc) SP_1_nachbar_vorne = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_SP_0"]) ) VP_1_nachbar_vorne = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_VP_0"]) ) # Ausrechnen des Offsets winkel_VP_offset_hinten = ( (SP_1_nachbar_vorne[0] - VP_1_nachbar_vorne[0]) * math.cos(math.radians(3)) + (SP_1_nachbar_vorne[2] - VP_1_nachbar_vorne[2]) * math.sin(math.radians(3)), VP_1_nachbar_vorne[1], -(SP_1_nachbar_vorne[0] - VP_1_nachbar_vorne[0]) * math.sin(math.radians(3)) + (SP_1_nachbar_vorne[2] - VP_1_nachbar_vorne[2]) * math.cos(math.radians(3)), ) 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 = block_methoden.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_hinten = ( (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 and voerder_richtung != "Horizontal" ): if gefaellestrecke_vario.get("Foerderrichtung") == "Auf": # 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_ab_{winkel_hinten_plusbogen}°" att_hinten = block_methoden.import_block( blockname, lib_doc, doc ) SP_0_nachbar_hinten = list( float(att) for att in re.split(r"[;,]", att_hinten["DELTA_SP_1"]) ) VP_0_nachbar_hinten = list( float(att) for att in re.split(r"[;,]", att_hinten["DELTA_VP_1"]) ) # Ausrechnung des Offsets winkel_VP_offset_vorne = ( (SP_0_nachbar_hinten[0] - VP_0_nachbar_hinten[0]) * math.cos(math.radians(-winkel_hinten)) + (SP_0_nachbar_hinten[2] - VP_0_nachbar_hinten[2]) * math.sin(math.radians(-winkel_hinten)), VP_0_nachbar_hinten[1], -(SP_0_nachbar_hinten[0] - VP_0_nachbar_hinten[0]) * math.sin(math.radians(-winkel_hinten)) + (SP_0_nachbar_hinten[2] - VP_0_nachbar_hinten[2]) * math.cos(math.radians(-winkel_hinten)), ) 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_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 = block_methoden.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_vorne = ( (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)), ) elif voerder_richtung == "Horizontal": winkel_vorne_plusbogen = ( int(gefaellestrecke_vario.get("Winkel")) + 3 ) winkel_hinten = int(gefaellestrecke_vario.get("Winkel")) blockname = f"Vario_Bogen_auf_{winkel_vorne_plusbogen}°" att_vorne = block_methoden.import_block(blockname, lib_doc, doc) SP_0_nachbar_hinten = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_SP_1"]) ) VP_0_nachbar_hinten = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_VP_1"]) ) SP_1_nachbar_vorne = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_SP_0"]) ) VP_1_nachbar_vorne = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_VP_0"]) ) x_foerderer = gefaellestrecke_vario.get("X_foerderer") y_foerderer = gefaellestrecke_vario.get("Y_foerderer") x = foerderer.x y = foerderer.y rotation_zwischen = rotation if rotation_zwischen == 0.0: rotation_zwischen = -360.0 if ( ((-360.0 <= rotation_zwischen < -270.0) and y > y_foerderer) or ((-90.0 < rotation < 0.0) and y > y_foerderer) or ((-270.0 < rotation_zwischen < -90.0) and y < y_foerderer) or (rotation == -90.0 and x < x_foerderer) or ((rotation == -270.0) and x < x_foerderer) ): blockname = f"Vario_Bogen_auf_{winkel_vorne_plusbogen}°" att_vorne = block_methoden.import_block(blockname, lib_doc, doc) SP_1_nachbar_vorne = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_SP_0"]) ) VP_1_nachbar_vorne = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_VP_0"]) ) winkel_VP_offset_vorne = ( (SP_1_nachbar_vorne[0] - VP_1_nachbar_vorne[0]) * math.cos(math.radians(3)) + (SP_1_nachbar_vorne[2] - VP_1_nachbar_vorne[2]) * math.sin(math.radians(3)), VP_1_nachbar_vorne[1], -(SP_1_nachbar_vorne[0] - VP_1_nachbar_vorne[0]) * math.sin(math.radians(3)) + (SP_1_nachbar_vorne[2] - VP_1_nachbar_vorne[2]) * math.cos(math.radians(3)), ) else: blockname = f"Vario_Bogen_ab_{winkel_vorne_plusbogen}°" att_hinten = block_methoden.import_block( blockname, lib_doc, doc ) SP_0_nachbar_hinten = list( float(att) for att in re.split(r"[;,]", att_hinten["DELTA_SP_1"]) ) VP_0_nachbar_hinten = list( float(att) for att in re.split(r"[;,]", att_hinten["DELTA_VP_1"]) ) winkel_VP_offset_hinten = ( (SP_0_nachbar_hinten[0] - VP_0_nachbar_hinten[0]) * math.cos(math.radians(-winkel_hinten)) + (SP_0_nachbar_hinten[2] - VP_0_nachbar_hinten[2]) * math.sin(math.radians(-winkel_hinten)), VP_0_nachbar_hinten[1], -(SP_0_nachbar_hinten[0] - VP_0_nachbar_hinten[0]) * math.sin(math.radians(-winkel_hinten)) + (SP_0_nachbar_hinten[2] - VP_0_nachbar_hinten[2]) * math.cos(math.radians(-winkel_hinten)), ) else: blockname = f"Vario_Kurve_{gefaellestrecke_vario.get("Kurvenrichtung")}_{gefaellestrecke_vario.get("Kurvenwinkel")}°_TEF_{gefaellestrecke_vario.get("Tefkurve")}" att_kurve = block_methoden.import_block(blockname, lib_doc, doc) SP_0_nachbar = list( float(att) for att in re.split(r"[;,]", att_kurve["DELTA_SP_0"]) ) VP_0_nachbar = list( float(att) for att in re.split(r"[;,]", att_kurve["DELTA_VP_0"]) ) SP_1_nachbar = list( float(att) for att in re.split(r"[;,]", att_kurve["DELTA_SP_1"]) ) VP_1_nachbar = list( float(att) for att in re.split(r"[;,]", att_kurve["DELTA_VP_1"]) ) if (SP_1_nachbar[0] < 0 and VP_1_nachbar[0] < 0) or ( SP_1_nachbar[0] >= 0 and VP_1_nachbar[0] < 0 ): SP_1_nachbar[0] = SP_1_nachbar[0] * -1 VP_1_nachbar[0] = VP_1_nachbar[0] * -1 if (SP_0_nachbar[1] < 0 and VP_0_nachbar[1] < 0) or ( SP_0_nachbar[1] >= 0 and VP_0_nachbar[1] < 0 ): SP_0_nachbar[1] = SP_0_nachbar[1] * -1 VP_0_nachbar[1] = VP_0_nachbar[1] * -1 if voerder_richtung == "Ab": if ( float(gefaellestrecke_vario.get("vario_hoehe_1")) == lower_hoehe_vario ): winkel_VP_offset_hinten = ( (SP_1_nachbar[0] - VP_1_nachbar[0]), 0, (SP_1_nachbar[2] - VP_1_nachbar[2]), ) else: winkel_VP_offset_vorne = ( (SP_0_nachbar[1] - VP_0_nachbar[1]), 0, (SP_1_nachbar[2] - VP_0_nachbar[2]), ) else: x_angetrieben = gefaellestrecke_vario.get("X_angetrieben") y_angetrieben = gefaellestrecke_vario.get("Y_angetrieben") x = foerderer.x y = foerderer.y rotation_zwischen = rotation if rotation_zwischen == 0.0: rotation_zwischen = -360.0 if ( ((-360.0 <= rotation_zwischen < -270.0) and y > y_angetrieben) or ((-90.0 < rotation < 0.0) and y > y_angetrieben) or ((-270.0 < rotation_zwischen < -90.0) and y < y_angetrieben) or (rotation == -90.0 and x < x_angetrieben) or ((rotation == -270.0) and x < x_angetrieben) ): winkel_VP_offset_hinten = ( (SP_0_nachbar[1] - VP_0_nachbar[1]), 0, (SP_1_nachbar[2] - VP_0_nachbar[2]), ) else: winkel_VP_offset_vorne = ( (SP_1_nachbar[0] - VP_1_nachbar[0]), 0, (SP_1_nachbar[2] - VP_1_nachbar[2]), ) # 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_1") != 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_2") != None: if ( float(gefaellestrecke_vario.get("h0_2")) == lower_hoehe_vario and voerder_richtung != "Horizontal" ): if gefaellestrecke_vario.get("Foerderrichtung_2") == "Auf": # 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_auf_{winkel_vorne_plusbogen}°" att_vorne = block_methoden.import_block(blockname, lib_doc, doc) SP_1_nachbar_vorne = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_SP_0"]) ) VP_1_nachbar_vorne = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_VP_0"]) ) # Ausrechnen des Offsets winkel_VP_offset_hinten = ( (SP_1_nachbar_vorne[0] - VP_1_nachbar_vorne[0]) * math.cos(math.radians(3)) + (SP_1_nachbar_vorne[2] - VP_1_nachbar_vorne[2]) * math.sin(math.radians(3)), VP_1_nachbar_vorne[1], -(SP_1_nachbar_vorne[0] - VP_1_nachbar_vorne[0]) * math.sin(math.radians(3)) + (SP_1_nachbar_vorne[2] - VP_1_nachbar_vorne[2]) * math.cos(math.radians(3)), ) elif gefaellestrecke_vario.get("Foerderrichtung_2") == "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_2")) - 3 ) winkel_vorne = int(gefaellestrecke_vario.get("Winkel_2")) blockname = f"Vario_Bogen_ab_{winkel_vorne_minusbogen}°" att_vorne = block_methoden.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_hinten = ( (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 and voerder_richtung != "Horizontal" ): if gefaellestrecke_vario.get("Foerderrichtung_2") == "Auf": # 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 ) winkel_hinten = int(gefaellestrecke_vario.get("Winkel_2")) blockname = f"Vario_Bogen_ab_{winkel_hinten_plusbogen}°" att_hinten = block_methoden.import_block( blockname, lib_doc, doc ) SP_0_nachbar_hinten = list( float(att) for att in re.split(r"[;,]", att_hinten["DELTA_SP_1"]) ) VP_0_nachbar_hinten = list( float(att) for att in re.split(r"[;,]", att_hinten["DELTA_VP_1"]) ) # Ausrechnung des Offsets winkel_VP_offset_vorne = ( (SP_0_nachbar_hinten[0] - VP_0_nachbar_hinten[0]) * math.cos(math.radians(-winkel_hinten)) + (SP_0_nachbar_hinten[2] - VP_0_nachbar_hinten[2]) * math.sin(math.radians(-winkel_hinten)), VP_0_nachbar_hinten[1], -(SP_0_nachbar_hinten[0] - VP_0_nachbar_hinten[0]) * math.sin(math.radians(-winkel_hinten)) + (SP_0_nachbar_hinten[2] - VP_0_nachbar_hinten[2]) * math.cos(math.radians(-winkel_hinten)), ) 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_hinten_minusbogen = ( int(gefaellestrecke_vario.get("Winkel_2")) - 3 ) winkel_hinten = int(gefaellestrecke_vario.get("Winkel_2")) blockname = f"Vario_Bogen_auf_{winkel_hinten_minusbogen}°" att_hinten = block_methoden.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_vorne = ( (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)), ) elif voerder_richtung == "Horizontal": winkel_vorne_plusbogen = ( int(gefaellestrecke_vario.get("Winkel_2")) + 3 ) winkel_hinten = int(gefaellestrecke_vario.get("Winkel_2")) blockname = f"Vario_Bogen_auf_{winkel_vorne_plusbogen}°" att_vorne = block_methoden.import_block(blockname, lib_doc, doc) SP_0_nachbar_hinten = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_SP_1"]) ) VP_0_nachbar_hinten = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_VP_1"]) ) SP_1_nachbar_vorne = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_SP_0"]) ) VP_1_nachbar_vorne = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_VP_0"]) ) x_foerderer = gefaellestrecke_vario.get("X_foerderer_2") y_foerderer = gefaellestrecke_vario.get("Y_foerderer_2") x = foerderer.x y = foerderer.y rotation_zwischen = rotation if rotation_zwischen == 0.0: rotation_zwischen = -360.0 if ( ((-360.0 <= rotation_zwischen < -270.0) and y > y_foerderer) or ((-90.0 < rotation < 0.0) and y > y_foerderer) or ((-270.0 < rotation_zwischen < -90.0) and y < y_foerderer) or (rotation == -90.0 and x < x_foerderer) or ((rotation == -270.0) and x < x_foerderer) ): blockname = f"Vario_Bogen_auf_{winkel_vorne_plusbogen}°" att_vorne = block_methoden.import_block(blockname, lib_doc, doc) SP_1_nachbar_vorne = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_SP_0"]) ) VP_1_nachbar_vorne = list( float(att) for att in re.split(r"[;,]", att_vorne["DELTA_VP_0"]) ) winkel_VP_offset_vorne = ( (SP_1_nachbar_vorne[0] - VP_1_nachbar_vorne[0]) * math.cos(math.radians(3)) + (SP_1_nachbar_vorne[2] - VP_1_nachbar_vorne[2]) * math.sin(math.radians(3)), VP_1_nachbar_vorne[1], -(SP_1_nachbar_vorne[0] - VP_1_nachbar_vorne[0]) * math.sin(math.radians(3)) + (SP_1_nachbar_vorne[2] - VP_1_nachbar_vorne[2]) * math.cos(math.radians(3)), ) else: blockname = f"Vario_Bogen_ab_{winkel_vorne_plusbogen}°" att_hinten = block_methoden.import_block( blockname, lib_doc, doc ) SP_0_nachbar_hinten = list( float(att) for att in re.split(r"[;,]", att_hinten["DELTA_SP_1"]) ) VP_0_nachbar_hinten = list( float(att) for att in re.split(r"[;,]", att_hinten["DELTA_VP_1"]) ) winkel_VP_offset_hinten = ( (SP_0_nachbar_hinten[0] - VP_0_nachbar_hinten[0]) * math.cos(math.radians(-winkel_hinten)) + (SP_0_nachbar_hinten[2] - VP_0_nachbar_hinten[2]) * math.sin(math.radians(-winkel_hinten)), VP_0_nachbar_hinten[1], -(SP_0_nachbar_hinten[0] - VP_0_nachbar_hinten[0]) * math.sin(math.radians(-winkel_hinten)) + (SP_0_nachbar_hinten[2] - VP_0_nachbar_hinten[2]) * math.cos(math.radians(-winkel_hinten)), ) else: blockname = f"Vario_Kurve_{gefaellestrecke_vario.get("Kurvenrichtung_1")}_{gefaellestrecke_vario.get("Kurvenwinkel_1")}°_TEF_{gefaellestrecke_vario.get("Tefkurve_1")}" att_kurve = block_methoden.import_block(blockname, lib_doc, doc) SP_0_nachbar = list( float(att) for att in re.split(r"[;,]", att_kurve["DELTA_SP_0"]) ) VP_0_nachbar = list( float(att) for att in re.split(r"[;,]", att_kurve["DELTA_VP_0"]) ) SP_1_nachbar = list( float(att) for att in re.split(r"[;,]", att_kurve["DELTA_SP_1"]) ) VP_1_nachbar = list( float(att) for att in re.split(r"[;,]", att_kurve["DELTA_VP_1"]) ) if (SP_1_nachbar[0] < 0 and VP_1_nachbar[0] < 0) or ( SP_1_nachbar[0] >= 0 and VP_1_nachbar[0] < 0 ): SP_1_nachbar[0] = SP_1_nachbar[0] * -1 VP_1_nachbar[0] = VP_1_nachbar[0] * -1 if (SP_0_nachbar[1] < 0 and VP_0_nachbar[1] < 0) or ( SP_0_nachbar[1] >= 0 and VP_0_nachbar[1] < 0 ): SP_0_nachbar[1] = SP_0_nachbar[1] * -1 VP_0_nachbar[1] = VP_0_nachbar[1] * -1 if voerder_richtung == "Ab": if ( float(gefaellestrecke_vario.get("vario_hoehe_1_1")) == lower_hoehe_vario ): winkel_VP_offset_hinten = ( (SP_1_nachbar[0] - VP_1_nachbar[0]), 0, (SP_1_nachbar[2] - VP_1_nachbar[2]), ) else: winkel_VP_offset_vorne = ( (SP_0_nachbar[1] - VP_0_nachbar[1]), 0, (SP_0_nachbar[2] - VP_0_nachbar[2]), ) else: x_angetrieben = gefaellestrecke_vario.get("X_angetrieben_1") y_angetrieben = gefaellestrecke_vario.get("Y_angetrieben_1") x = foerderer.x y = foerderer.y rotation_zwischen = rotation if rotation_zwischen == 0.0: rotation_zwischen = -360.0 if ( ((-360.0 <= rotation_zwischen < -270.0) and y > y_angetrieben) or ((-90.0 < rotation < 0.0) and y > y_angetrieben) or ((-270.0 < rotation_zwischen < -90.0) and y < y_angetrieben) or (rotation == -90.0 and x < x_angetrieben) or ((rotation == -270.0) and x < x_angetrieben) ): winkel_VP_offset_hinten = ( (SP_0_nachbar[1] - VP_0_nachbar[1]), 0, (SP_0_nachbar[2] - VP_0_nachbar[2]), ) else: winkel_VP_offset_vorne = ( (SP_1_nachbar[0] - VP_1_nachbar[0]), 0, (SP_1_nachbar[2] - VP_1_nachbar[2]), ) return winkel_VP_offset_vorne, winkel_VP_offset_hinten def horizontale_ausrichtung(foerderer, x0_kreisel, y0_kreisel): """Schaut was für eine Ausrichtung der Horizontale Förder hat""" voerder_richtung = foerderer.foerderer_richtung rotation = foerderer.drehung x = foerderer.x y = foerderer.y # mit_horizontal_verbunden None als String für einen späteren vergleich 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" return mit_horizontal_verbunden def vario_verbuden_am_kreisel( foerderer, block_vario, start, ende, mit_horizontal_verbunden=None, kreisel_verbunden=None, am_kreisel=None, erster_kreisel_höher=None, ): """ ""Methode für Erstellung der Gefällestrecke für Vario Förderrer die direkt am dem Kreisel hängt""" lower_hoehe_vario = foerderer.h0 upper_hoehe_vario = foerderer.h1 voerder_richtung = foerderer.foerderer_richtung hoehe_vario = foerderer.hight_zwischen x = foerderer.x y = foerderer.y gefaelle_länge = 500 if ( kreisel_verbunden == 2 or (am_kreisel == 1 and erster_kreisel_höher == True) or (am_kreisel == 2 and erster_kreisel_höher == False) ) and voerder_richtung != "Horizontal": 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] - gefaelle_länge * math.cos(math.radians(3)), upper_hoehe_vario + gefaelle_länge * math.sin(math.radians(3)), ) start = m elif voerder_richtung == "Ab": m = ( start[0], start[1] - gefaelle_länge * math.cos(math.radians(3)), upper_hoehe_vario - gefaelle_länge * math.sin(math.radians(3)), ) start = m else: m = ( start[0], start[1] - gefaelle_länge * math.cos(math.radians(3)), upper_hoehe_vario, ) start = m if kreisel_verbunden == 1: z1 = m[2] y1 = start[1] 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) if ( kreisel_verbunden == 2 or (am_kreisel == 1 and erster_kreisel_höher == False) or (am_kreisel == 2 and erster_kreisel_höher == True) ) and voerder_richtung != "Horizontal": l = (ende[0], ende[1], lower_hoehe_vario) if voerder_richtung == "Auf": m = ( ende[0], ende[1] + gefaelle_länge * math.cos(math.radians(3)), lower_hoehe_vario - gefaelle_länge * math.sin(math.radians(3)), ) ende = m elif voerder_richtung == "Ab": m = ( ende[0], ende[1] + gefaelle_länge * math.cos(math.radians(3)), lower_hoehe_vario + gefaelle_länge * math.sin(math.radians(3)), ) ende = m else: m = ( ende[0], ende[1] + gefaelle_länge * 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) if kreisel_verbunden == 1: z1 = m[2] y1 = ende[1] 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] - gefaelle_länge * 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] + gefaelle_länge * 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) if kreisel_verbunden == 1 and mit_horizontal_verbunden == None: return y1, z1 else: return start, ende def vario_erstellung( foerderer, doc, lib_doc, config, block, block_name_links, start, ende, voerder_richtung, winkel_VP_offset_vorne, winkel_VP_offset_hinten, ): """Erstellung der Vario Blöcke""" # Entnehmen der Motor und Umlenk station um die Gefähle auzurechnen und ob man diese tatsächlich einfügen muss winkel_motor = float(config.get("Ils 2.0 core winkel", "winkel_motor")) winkel_umlenk = float(config.get("Ils 2.0 core winkel", "winkel_umlenk")) umlenk_laenge = tuple( float(x) for x in (config.get("ILS 2.0 Variofoerderer", "Umlenkstation")).split(",") ) motor_laenge = tuple( float(x) for x in (config.get("ILS 2.0 Variofoerderer", "Motorstation")).split(",") ) vario_abstand = float(config.get("ILS 2.0 Variofoerderer", "vario_abstand")) motor_vorhanden = foerderer.hat_motor umlenk_vorhanden = foerderer.hat_umlenk gefahellewinkel = foerderer.gefaelle_winkel gefaelle = foerderer.gefaelle_laenge x = foerderer.x y = foerderer.y hoehe_vario = foerderer.hight_zwischen winkel = int(foerderer.winkel) # 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) motor_offset_x = umlenk_laenge[0] * math.cos(math.radians(winkel_motor)) motor_offset_z = umlenk_laenge[0] * math.sin(math.radians(winkel_motor)) umlenk_offset_x = motor_laenge[0] * math.cos(math.radians(winkel_umlenk)) umlenk_offset_z = motor_laenge[0] * math.sin(math.radians(winkel_umlenk)) # Berechnung des Gefälles if motor_vorhanden == True: gefaelle = gefaelle - motor_offset_x if umlenk_vorhanden == True: gefaelle = gefaelle - umlenk_offset_x # 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" block_methoden.import_block(block_Vario_Motorstation_500mm, lib_doc, doc) block_methoden.import_block(block_Vario_Umlenkstation_500mm, lib_doc, doc) layer_motor, color_motor = block_methoden.get_insert_color_layer( lib_doc, block_Vario_Motorstation_500mm ) layer_umlenk, color_umlenk = block_methoden.get_insert_color_layer( lib_doc, block_Vario_Umlenkstation_500mm ) block_Vario_Motorstation_500mm = block_methoden.dreh_block( block_Vario_Motorstation_500mm, doc, lib_doc, math.radians(winkel_motor) ) block_Vario_Umlenkstation_500mm = block_methoden.dreh_block( block_Vario_Umlenkstation_500mm, doc, lib_doc, math.radians(winkel_umlenk), ) if umlenk_vorhanden == True: block.add_blockref( block_Vario_Umlenkstation_500mm, ( ende[0] - x, ende[1] - y + umlenk_offset_x / 2, ende[2] - hoehe_vario - umlenk_offset_z / 2, ), dxfattribs={ "rotation": 90, "layer": layer_umlenk, "color": color_umlenk, }, ) ende = (ende[0], ende[1] + umlenk_offset_x, ende[2] - umlenk_offset_z) if motor_vorhanden == True: block.add_blockref( block_Vario_Motorstation_500mm, ( start[0] - x, start[1] - motor_offset_x / 2 - y, start[2] - hoehe_vario + motor_offset_z / 2, ), dxfattribs={ "rotation": 90, "layer": layer_motor, "color": color_motor, }, ) start = start[0], start[1] - motor_offset_x, start[2] + motor_offset_z # Einfügen der 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 = 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 = block_methoden.import_block( block_Vario_Bogen_auf, lib_doc, doc ) ab_attrib = block_methoden.import_block(block_Vario_Bogen_ab, lib_doc, doc) layer_auf, color_auf = block_methoden.get_insert_color_layer( lib_doc, block_Vario_Bogen_auf ) layer_ab, color_ab = block_methoden.get_insert_color_layer( lib_doc, block_Vario_Bogen_ab ) block_Vario_Bogen_auf = block_methoden.dreh_block( block_Vario_Bogen_auf, doc, lib_doc, math.radians(winkel_core) ) block_Vario_Bogen_ab = block_methoden.dreh_block( block_Vario_Bogen_ab, doc, lib_doc, math.radians(-winkel) ) # Entnehmen der Werte von den Attributen 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"]) ) # Werte von den Attributen durch den Winkel ändern wegen der Neugung in 3 Dimensionalen raum 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 if voerder_richtung == "Auf": 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, "layer": layer_auf, "color": color_auf}, ) 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, "layer": layer_ab, "color": color_ab}, ) 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: if umlenk_vorhanden == True: 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, "layer": layer_ab, "color": color_ab, }, ) 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], ) else: start_VP = ( start[0] + vario_abstand, start[1] + winkel_VP_offset_hinten[0], start[2] - winkel_VP_offset_hinten[2], ) # einfügen des auf blockes und veränderund der start Punktes dementsprechend und erstellung von startVP für die VARIO linie if motor_vorhanden == True: 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, "layer": layer_auf, "color": color_auf, }, ) 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], ) else: ende_VP = ( ende[0] + vario_abstand, ende[1] - winkel_VP_offset_vorne[0], ende[2] - winkel_VP_offset_vorne[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" block_methoden.import_block(block_Vario_Motorstation_500mm, lib_doc, doc) block_methoden.import_block(block_Vario_Umlenkstation_500mm, lib_doc, doc) layer_motor, color_motor = block_methoden.get_insert_color_layer( lib_doc, block_Vario_Motorstation_500mm ) layer_umlenk, color_umlenk = block_methoden.get_insert_color_layer( lib_doc, block_Vario_Umlenkstation_500mm ) block_Vario_Motorstation_500mm = block_methoden.dreh_block( block_Vario_Motorstation_500mm, doc, lib_doc, math.radians(winkel_motor) ) block_Vario_Umlenkstation_500mm = block_methoden.dreh_block( block_Vario_Umlenkstation_500mm, doc, lib_doc, math.radians(winkel_umlenk), ) if umlenk_vorhanden == True: block.add_blockref( block_Vario_Umlenkstation_500mm, ( start[0] - x, start[1] - y - umlenk_offset_x / 2, start[2] - hoehe_vario - umlenk_offset_z / 2, ), dxfattribs={ "rotation": 270, "layer": layer_umlenk, "color": color_umlenk, }, ) start_Umlenkstation_VP = ( start[0] - vario_abstand, 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_offset_x, start[2] - umlenk_offset_z, ) elif winkel == 3: start_Umlenkstation_VP = ( start[0] - vario_abstand, start[1] + winkel_VP_offset_vorne[0], start[2] - winkel_VP_offset_vorne[2], ) if motor_vorhanden == True: block.add_blockref( block_Vario_Motorstation_500mm, ( ende[0] - x, ende[1] + motor_offset_x / 2 - y, ende[2] - hoehe_vario + motor_offset_z / 2, ), dxfattribs={ "rotation": 270, "layer": layer_motor, "color": color_motor, }, ) ende_Motor_VP = ( ende[0] - vario_abstand, 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] + motor_offset_x, ende[2] + motor_offset_z elif winkel == 3: ende_Motor_VP = ( ende[0] - vario_abstand, ende[1] - winkel_VP_offset_vorne[0], ende[2] - winkel_VP_offset_hinten[2], ) if winkel != 3: winkel_core = int(config.get("Ils 2.0 core winkel", "winkel_boegen")) winkel_minus = 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 = block_methoden.import_block( block_Vario_Bogen_ab, lib_doc, doc ) auf_attrib = block_methoden.import_block( block_Vario_Bogen_auf, lib_doc, doc ) layer_auf, color_auf = block_methoden.get_insert_color_layer( lib_doc, block_Vario_Bogen_auf ) layer_ab, color_ab = block_methoden.get_insert_color_layer( lib_doc, block_Vario_Bogen_ab ) block_Vario_Bogen_ab = block_methoden.dreh_block( block_Vario_Bogen_ab, doc, lib_doc, math.radians(winkel_core) ) block_Vario_Bogen_auf = block_methoden.dreh_block( block_Vario_Bogen_auf, doc, lib_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, "layer": layer_ab, "color": color_ab}, ) 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, "layer": layer_auf, "color": color_auf, }, ) 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) # Sonderlogik für grad 3, weil es kein bogen braucht 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.startswith("400102632_ES-Element_90_links") or entity.dxf.name.startswith("200000146_ES-Element_90_rechts") or entity.dxf.name.startswith("200000241_AS-Element_90_rechts") or entity.dxf.name.startswith("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)