Block_methoden in einen eigen File refactored

This commit is contained in:
2025-12-18 08:35:41 +01:00
parent 843011bab9
commit e46ff3bd1b
7 changed files with 335 additions and 321 deletions
+42 -40
View File
@@ -5,6 +5,8 @@ from typing import Optional
import plant2dxf
from ezdxf.math import Matrix44
import re
import block_methoden
class VarioFoerderer(BaseModel):
teileid: str
@@ -77,7 +79,7 @@ class VarioFoerderer(BaseModel):
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 =plant2dxf.import_block(blockname,lib_doc,doc)
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
@@ -89,7 +91,7 @@ class VarioFoerderer(BaseModel):
winkel_vorne = int(gefaellestrecke_vario.get("Winkel"))
blockname = (f"Vario_Bogen_ab_{winkel_vorne_minusbogen}°")
att_vorne =plant2dxf.import_block(blockname,lib_doc,doc)
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
@@ -102,7 +104,7 @@ class VarioFoerderer(BaseModel):
winkel_hinten = int(gefaellestrecke_vario.get("Winkel"))
blockname = (f"Vario_Bogen_ab_{winkel_hinten_plusbogen}°")
att_hinten =plant2dxf.import_block(blockname,lib_doc,doc)
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
@@ -114,7 +116,7 @@ class VarioFoerderer(BaseModel):
winkel_hinten = int(gefaellestrecke_vario.get("Winkel"))
blockname = (f"Vario_Bogen_auf_{winkel_hinten_minusbogen}°")
att_hinten =plant2dxf.import_block(blockname,lib_doc,doc)
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
@@ -123,7 +125,7 @@ class VarioFoerderer(BaseModel):
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 =plant2dxf.import_block(blockname,lib_doc,doc)
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"]))
@@ -139,13 +141,13 @@ class VarioFoerderer(BaseModel):
((-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 =plant2dxf.import_block(blockname,lib_doc,doc)
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 =plant2dxf.import_block(blockname,lib_doc,doc)
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))
@@ -153,7 +155,7 @@ class VarioFoerderer(BaseModel):
else:
blockname = (f"Vario_Kurve_{gefaellestrecke_vario.get("Kurvenrichtung")}_{gefaellestrecke_vario.get("Kurvenwinkel")}°_TEF_{gefaellestrecke_vario.get("Tefkurve")}")
att_kurve = plant2dxf.import_block(blockname,lib_doc,doc)
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"]))
@@ -197,7 +199,7 @@ class VarioFoerderer(BaseModel):
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 =plant2dxf.import_block(blockname,lib_doc,doc)
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
@@ -209,7 +211,7 @@ class VarioFoerderer(BaseModel):
winkel_vorne = int(gefaellestrecke_vario.get("Winkel_2"))
blockname = (f"Vario_Bogen_ab_{winkel_vorne_minusbogen}°")
att_vorne =plant2dxf.import_block(blockname,lib_doc,doc)
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
@@ -222,7 +224,7 @@ class VarioFoerderer(BaseModel):
winkel_hinten = int(gefaellestrecke_vario.get("Winkel_2"))
blockname = (f"Vario_Bogen_ab_{winkel_hinten_plusbogen}°")
att_hinten =plant2dxf.import_block(blockname,lib_doc,doc)
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
@@ -234,7 +236,7 @@ class VarioFoerderer(BaseModel):
winkel_hinten = int(gefaellestrecke_vario.get("Winkel_2"))
blockname = (f"Vario_Bogen_auf_{winkel_hinten_minusbogen}°")
att_hinten =plant2dxf.import_block(blockname,lib_doc,doc)
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
@@ -243,7 +245,7 @@ class VarioFoerderer(BaseModel):
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 =plant2dxf.import_block(blockname,lib_doc,doc)
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"]))
@@ -259,19 +261,19 @@ class VarioFoerderer(BaseModel):
((-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 =plant2dxf.import_block(blockname,lib_doc,doc)
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 =plant2dxf.import_block(blockname,lib_doc,doc)
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 = plant2dxf.import_block(blockname,lib_doc,doc)
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"]))
@@ -376,12 +378,12 @@ class VarioFoerderer(BaseModel):
# 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"
plant2dxf.import_block(block_Vario_Motorstation_500mm, lib_doc, doc)
plant2dxf.import_block(block_Vario_Umlenkstation_500mm , lib_doc, doc)
layer_motor, color_motor = plant2dxf.get_insert_color_layer(lib_doc,block_Vario_Motorstation_500mm)
layer_umlenk, color_umlenk = plant2dxf.get_insert_color_layer(lib_doc,block_Vario_Umlenkstation_500mm)
block_Vario_Motorstation_500mm = plant2dxf.dreh_block(block_Vario_Motorstation_500mm,doc,lib_doc,math.radians(winkel_motor))
block_Vario_Umlenkstation_500mm = plant2dxf.dreh_block( block_Vario_Umlenkstation_500mm, doc,lib_doc,math.radians(winkel_umlenk))
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)
@@ -395,12 +397,12 @@ class VarioFoerderer(BaseModel):
block_Vario_Bogen_auf = (f"Vario_Bogen_auf_{winkel_plus}°")
block_Vario_Bogen_ab = (f"Vario_Bogen_ab_{winkel_plus}°")
auf_attrib =plant2dxf.import_block(block_Vario_Bogen_auf, lib_doc, doc)
ab_attrib =plant2dxf.import_block(block_Vario_Bogen_ab, lib_doc, doc)
layer_auf,color_auf = plant2dxf.get_insert_color_layer(lib_doc,block_Vario_Bogen_auf)
layer_ab,color_ab =plant2dxf.get_insert_color_layer(lib_doc,block_Vario_Bogen_ab)
block_Vario_Bogen_auf = plant2dxf.dreh_block(block_Vario_Bogen_auf, doc,lib_doc,math.radians(winkel_core))
block_Vario_Bogen_ab = plant2dxf.dreh_block(block_Vario_Bogen_ab, doc,lib_doc,math.radians(-winkel))
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))
Vario_Bogen_auf_Delta_SP_0 = list(float(att)for att in re.split(r"[;,]", auf_attrib["DELTA_SP_0"]))
@@ -538,12 +540,12 @@ class VarioFoerderer(BaseModel):
# Importieren und setzen der UMlenkungstation oder Motorstation falls nötig
block_Vario_Umlenkstation_500mm ="Vario_Umlenkstation_500mm"
block_Vario_Motorstation_500mm = "Vario_Motorstation_500mm"
plant2dxf.import_block( block_Vario_Motorstation_500mm, lib_doc, doc)
plant2dxf.import_block( block_Vario_Umlenkstation_500mm , lib_doc, doc)
layer_motor, color_motor = plant2dxf.get_insert_color_layer(lib_doc,block_Vario_Motorstation_500mm)
layer_umlenk, color_umlenk = plant2dxf.get_insert_color_layer(lib_doc,block_Vario_Umlenkstation_500mm)
block_Vario_Motorstation_500mm = plant2dxf.dreh_block( block_Vario_Motorstation_500mm, doc,lib_doc,math.radians(winkel_motor))
block_Vario_Umlenkstation_500mm = plant2dxf.dreh_block( block_Vario_Umlenkstation_500mm , doc,lib_doc,math.radians(winkel_umlenk))
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
@@ -562,12 +564,12 @@ class VarioFoerderer(BaseModel):
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 =plant2dxf.import_block( block_Vario_Bogen_ab , lib_doc, doc)
auf_attrib =plant2dxf.import_block( block_Vario_Bogen_auf, lib_doc, doc)
layer_auf,color_auf = plant2dxf.get_insert_color_layer(lib_doc,block_Vario_Bogen_auf)
layer_ab,color_ab =plant2dxf.get_insert_color_layer(lib_doc,block_Vario_Bogen_ab)
block_Vario_Bogen_ab = plant2dxf.dreh_block( block_Vario_Bogen_ab, doc,lib_doc, math.radians(winkel_core))
block_Vario_Bogen_auf= plant2dxf.dreh_block( block_Vario_Bogen_auf, doc,lib_doc, math.radians(winkel))
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"]))