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
+25 -234
View File
@@ -20,6 +20,7 @@ import math
from utils import check_environment_var, setup_logger
from Elemente import Kreisel, VarioFoerderer,Gefaehllestrecke,Angetriebene_Kurve,Bt_element,Omniflo
import as_es_methoden
import block_methoden
@@ -84,101 +85,7 @@ def parse_merkmale(merkmale_str: str) -> dict:
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
"""
msp2 = from_doc.modelspace()
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,lib_doc, winkel) :
"""Nimmt ein schon importierten Block und erstellt einen neuen der an der y_axis oder x_axis gedreht wird
"""
dreh_block_name = block_name +f"_{math.degrees(winkel)}"
layer, color = get_insert_color_layer(lib_doc,block_name)
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))
if block_name == "200000146_ES-Element_90_rechts" or block_name =="400102632_ES-Element_90_links" or block_name =="200000241_AS-Element_90_rechts" or block_name =="200000217_AS-Element_90_links":
rotation_matrix = Matrix44.axis_rotate(X_AXIS, winkel)
else:
rotation_matrix = Matrix44.axis_rotate(Y_AXIS, winkel)
block_zwischen.add_blockref(block_name,(0,0,0),dxfattribs={"layer":layer,"color": color})
for e in block_zwischen:
copy = e.copy()
copy.transform(rotation_matrix)
block.add_entity(copy)
return dreh_block_name
def handle_ils_2_0_kreisel(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols,strecken_nachbarn,config,config_allgemein):
"""Erstellt ein Kreisel in der neuen Dxf"""
kreisel = Kreisel.Kreisel.from_merkmale(teileid, x, y, merkmale)
@@ -188,8 +95,8 @@ def handle_ils_2_0_kreisel(msp, teileid, merkmale, x, y, doc, lib_doc, verbose,
scanner_y = kreisel.y
separatoren_x = kreisel.x
separatoren_y = kreisel.y + 160
import_block(block_scanner,lib_doc,doc)
import_block(block_separatoren,lib_doc,doc)
block_methoden.import_block(block_scanner,lib_doc,doc)
block_methoden.import_block(block_separatoren,lib_doc,doc)
i = 0
while i < kreisel.anzahl_scanner:
msp.add_blockref(block_scanner, (scanner_x,scanner_y, kreisel.hoehe))
@@ -212,22 +119,22 @@ def handle_ils_2_0_kreisel(msp, teileid, merkmale, x, y, doc, lib_doc, verbose,
rotation = sym["rotation"]
if i < len(positions):
pos = (positions[i][0] + offset[0], positions[i][1] + offset[1], kreisel.hoehe)
import_block(blockname, lib_doc, doc)
blockref_layer, color = get_insert_color_layer(lib_doc, blockname)
block_methoden.import_block(blockname, lib_doc, doc)
blockref_layer, color = block_methoden.get_insert_color_layer(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)
block_methoden.import_block("Pinbereich",lib_doc,doc)
Kreisel.Kreisel.draw_kreisel_lines(msp, pos1, pos2, kreisel)
Kreisel.Kreisel.draw_kreisel_drehrichtung_markierung(msp, pos1, pos2, kreisel, lib_doc, doc, verbose)
def handle_ils_2_0_eckrad(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
"""Erstellt ein Eckrad in der neuen Dxf"""
import_block("AN8",lib_doc,doc)
import_block("Richtungspfeil",lib_doc,doc)
block_methoden.import_block("AN8",lib_doc,doc)
block_methoden.import_block("Richtungspfeil",lib_doc,doc)
eckrad_rechts = "eckrad_UZS"
eckrad_links = "eckrad_GUZS"
hight = float(merkmale.get("Höhe in m"))
@@ -299,7 +206,7 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
rotation = rotation -180
gefaelle_objekt.drehung = rotation
block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links = rotatate_and_left_motor_umlenk(doc, lib_doc,config)
block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links = block_methoden.rotatate_and_left_motor_umlenk(doc, lib_doc,config)
hat_zusatz = Gefaehllestrecke.Gefaellestrecke.hat_motor_umlenk_station (gefaelle_objekt, gefaellestrecke_nachbarn)
hat_motor_0 = hat_zusatz.get("hat_motor_0")
hat_umlenk_0 = hat_zusatz.get("hat_umlenk_0")
@@ -331,7 +238,7 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
dy = halbe_laenge * math.cos(0)
start = [x , y + dy ,upper_hoehe_gefaehlle]
ende = [x , y - dy ,lower_hoehe_gefaehlle]
start, ende = ein_motor_oder_eine_umlenk(x, y,start,ende, doc, lib_doc, hoehe_gefaehlle, block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links, hat_motor_0, hat_umlenk_0, tefkurve_0, block,umlenk_gerade,motor_gerade)
start, ende = Gefaehllestrecke.Gefaellestrecke.ein_motor_oder_eine_umlenk(x, y,start,ende, doc, lib_doc, hoehe_gefaehlle, block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links, hat_motor_0, hat_umlenk_0, tefkurve_0, block,umlenk_gerade,motor_gerade)
line = Line.new(dxfattribs={"start":start,"end":ende})
line.translate(-x,-y,-hoehe_gefaehlle)
@@ -364,7 +271,7 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
dy = halbe_laenge * math.cos(0)
start = [x , y + dy ,upper_hoehe_gefaehlle]
ende = [x , y - dy ,lower_hoehe_gefaehlle]
start, ende = ein_motor_oder_eine_umlenk(x, y, start,ende,doc, lib_doc, hoehe_gefaehlle, block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links, hat_motor_0, hat_umlenk_0, tefkurve_0, block,umlenk_gerade,motor_gerade)
start, ende = Gefaehllestrecke.Gefaellestrecke.ein_motor_oder_eine_umlenk(x, y, start,ende,doc, lib_doc, hoehe_gefaehlle, block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links, hat_motor_0, hat_umlenk_0, tefkurve_0, block,umlenk_gerade,motor_gerade)
only_es_or_as = as_es_methoden.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)
@@ -534,7 +441,7 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
rotation = rotation -180
gefaelle_objekt.drehung = rotation
block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links = rotatate_and_left_motor_umlenk(doc, lib_doc,config)
block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links = block_methoden.rotatate_and_left_motor_umlenk(doc, lib_doc,config)
hat_zusatz = Gefaehllestrecke.Gefaellestrecke.hat_motor_umlenk_station(gefaelle_objekt, gefaellestrecke_nachbarn)
hat_motor_0 = hat_zusatz.get("hat_motor_0")
hat_umlenk_0 = hat_zusatz.get("hat_umlenk_0")
@@ -560,120 +467,14 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
dy = halbe_laenge * math.cos(0)
start = [x , y + dy ,upper_hoehe_gefaehlle]
ende = [x , y - dy ,lower_hoehe_gefaehlle]
start, ende = ein_motor_oder_eine_umlenk(x, y,start,ende, doc, lib_doc, hoehe_gefaehlle, block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links, hat_motor_0, hat_umlenk_0, tefkurve_0, block,umlenk_gerade,motor_gerade)
start, ende = ein_motor_oder_eine_umlenk(x, y,start,ende, doc, lib_doc, hoehe_gefaehlle, block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links, hat_motor_1, hat_umlenk_1, tefkurve_1, block,umlenk_gerade,motor_gerade)
start, ende = Gefaehllestrecke.Gefaellestrecke.ein_motor_oder_eine_umlenk(x, y,start,ende, doc, lib_doc, hoehe_gefaehlle, block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links, hat_motor_0, hat_umlenk_0, tefkurve_0, block,umlenk_gerade,motor_gerade)
start, ende = Gefaehllestrecke.Gefaellestrecke.ein_motor_oder_eine_umlenk(x, y,start,ende, doc, lib_doc, hoehe_gefaehlle, block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links, hat_motor_1, hat_umlenk_1, tefkurve_1, block,umlenk_gerade,motor_gerade)
line = Line.new(dxfattribs={"start":start,"end":ende})
line.dxf.layer = "6-SP"
line.translate(-x,-y,-hoehe_gefaehlle)
block.add_entity(line)
msp.add_blockref(blockname,(x,y,hoehe_gefaehlle),dxfattribs={"rotation": rotation,"layer": gefaelle_layer})
def ein_motor_oder_eine_umlenk(x, y,start,ende, doc, lib_doc, hoehe_gefaehlle, block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links, hat_motor_0, hat_umlenk_0, tefkurve_0, block,umlenk_gerade,motor_gerade):
block_Vario_Bogen_auf = (f"Vario_Bogen_auf_3°")
block_Vario_Bogen_ab = (f"Vario_Bogen_ab_3°")
block_Vario_Bogen_auf_links = (f"Vario_Bogen_auf_3°") + "_links"
block_Vario_Bogen_ab_links = (f"Vario_Bogen_ab_3°") + "_links"
auf_attrib = import_block(block_Vario_Bogen_auf,lib_doc,doc)
ab_attrib = import_block(block_Vario_Bogen_ab,lib_doc,doc)
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"]))
for i, wert in enumerate(Vario_Bogen_auf_Delta_SP_0):
if wert < 0:
Vario_Bogen_auf_Delta_SP_0[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_auf_Delta_SP_1):
if wert< 0:
Vario_Bogen_auf_Delta_SP_1[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_ab_Delta_SP_0):
if wert< 0:
Vario_Bogen_ab_Delta_SP_0[i] = abs(wert)
for i, wert in enumerate(Vario_Bogen_ab_Delta_SP_1):
if wert< 0:
Vario_Bogen_ab_Delta_SP_1[i] = abs(wert)
turn_two_blocks_left(doc, block_Vario_Bogen_auf, block_Vario_Bogen_ab, block_Vario_Bogen_ab_links, block_Vario_Bogen_auf_links)
if hat_motor_0 == True:
if tefkurve_0 == "rechts":
if motor_gerade == False:
block.add_blockref(block_Vario_Bogen_ab,(start[0]-x,start[1]-Vario_Bogen_ab_Delta_SP_0[0]-y,start[2]- Vario_Bogen_ab_Delta_SP_0[2]-hoehe_gefaehlle),dxfattribs={"rotation": 270})
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]]
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))
else:
block.add_blockref("Vario_Motorstation_500mm", (start[0]-x,start[1] -y,start[2] -hoehe_gefaehlle),dxfattribs={"rotation": 270})
start[1]= start[1] - 500
else:
if motor_gerade == False:
block.add_blockref(block_Vario_Bogen_ab_links,(start[0]-x,start[1]-Vario_Bogen_ab_Delta_SP_0[0]-y,start[2]- Vario_Bogen_ab_Delta_SP_0[2]-hoehe_gefaehlle),dxfattribs={"rotation": 270})
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]]
block.add_blockref(block_Vario_Motorstation_500mm, (start[0]-x,start[1] - 250* math.cos(math.radians(3))-y,start[2] - 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
start[1]= start[1] - 500* math.cos(math.radians(3))
start[2] = start[2] - 500* math.sin(math.radians(3))
else:
block.add_blockref("Vario_Motorstation_500mm_links", (start[0]-x,start[1] -y,start[2] -hoehe_gefaehlle),dxfattribs={"rotation": 270})
start[1]= start[1] - 500
if hat_umlenk_0 == True:
if tefkurve_0 == "rechts":
if umlenk_gerade == False:
block.add_blockref(block_Vario_Bogen_auf_links,(ende[0]-x,ende[1]+Vario_Bogen_auf_Delta_SP_0[0]-y,ende[2] + Vario_Bogen_auf_Delta_SP_0[2]-hoehe_gefaehlle),dxfattribs={"rotation": 90})
ende = [ende[0],ende[1]+ Vario_Bogen_auf_Delta_SP_0[0]+ Vario_Bogen_auf_Delta_SP_1[0],ende[2]+Vario_Bogen_auf_Delta_SP_0[2]+ Vario_Bogen_auf_Delta_SP_1[2]]
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))
else:
block.add_blockref("Vario_Umlenkstation_500mm", (ende[0]-x,ende[1] + 250-y,ende[2] -hoehe_gefaehlle),dxfattribs={"rotation": 270})
ende [1]= ende[1] + 500
else:
if umlenk_gerade == False:
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_gefaehlle),dxfattribs={"rotation": 90})
ende = [ende[0],ende[1]+ Vario_Bogen_auf_Delta_SP_0[0]+ Vario_Bogen_auf_Delta_SP_1[0],ende[2]+Vario_Bogen_auf_Delta_SP_0[2]+ Vario_Bogen_auf_Delta_SP_1[2]]
block.add_blockref(block_Vario_Umlenkstation_500mm, (ende[0]-x,ende[1] + 250* math.cos(math.radians(3))-y,ende[2] + 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
ende [1]= ende[1] + 500* math.cos(math.radians(3))
ende[2] = ende[2] + 500* math.sin(math.radians(3))
else:
block.add_blockref("Vario_Umlenkstation_500mm", (ende[0]-x,ende[1] + 250-y,ende[2] -hoehe_gefaehlle),dxfattribs={"rotation": 270})
ende [1]= ende[1] + 500
return start,ende
def rotatate_and_left_motor_umlenk(doc, lib_doc,config):
motor_rotation = float(config.get("Ils 2.0 core winkel","winkel_motor"))
umlenk_rotation = float(config.get("Ils 2.0 core winkel","winkel_umlenk"))
block_Vario_Umlenkstation_500mm ="Vario_Umlenkstation_500mm"
block_Vario_Motorstation_500mm = "Vario_Motorstation_500mm"
blockname_motor_links = block_Vario_Motorstation_500mm +"_links"
blockname_umlenk_links = block_Vario_Umlenkstation_500mm + "_links"
import_block(block_Vario_Umlenkstation_500mm,lib_doc,doc)
import_block(block_Vario_Motorstation_500mm,lib_doc,doc)
turn_two_blocks_left(doc, block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links)
block_Vario_Umlenkstation_500mm =dreh_block(block_Vario_Umlenkstation_500mm,doc,lib_doc,math.radians(umlenk_rotation))
block_Vario_Motorstation_500mm =dreh_block(block_Vario_Motorstation_500mm,doc,lib_doc,math.radians(motor_rotation))
blockname_motor_links =dreh_block(blockname_motor_links,doc,lib_doc,math.radians(umlenk_rotation))
blockname_umlenk_links =dreh_block(blockname_umlenk_links,doc,lib_doc,math.radians(motor_rotation))
return block_Vario_Umlenkstation_500mm,block_Vario_Motorstation_500mm,blockname_motor_links,blockname_umlenk_links
def turn_two_blocks_left(doc, block_1_name_zwischen, block_2_name, block_2_left_name, block_1_left_name):
if block_2_left_name not in doc.blocks:
matrix = Matrix44.scale(1,-1,1)
block_2 = doc.blocks.new(name=block_2_left_name,base_point=(0,0,0))
block_1_left_name = doc.blocks.new(name=block_1_left_name,base_point=(0,0,0))
block_2_zwischen = doc.blocks[block_2_name]
block_1_name_zwischen = doc.blocks[block_1_name_zwischen]
for e in block_2_zwischen:
copy = e.copy()
copy.transform(matrix)
block_2.add_entity(copy)
for e in block_1_name_zwischen:
copy = e.copy()
copy.transform(matrix)
block_1_left_name.add_entity(copy)
def anzahl_seperatoren_oder_scan(msp, x, y, doc, lib_doc, klassen_objekt, hoehe, rotation):
"""Importiert alle seperatoren und/oder scanner für das nötige objekt"""
separatoren = klassen_objekt.anzahl_separatoren
@@ -690,10 +491,10 @@ def anzahl_seperatoren_oder_scan(msp, x, y, doc, lib_doc, klassen_objekt, hoehe,
modular = 3
block_scanner = "SCAN"
block_separatoren = "S-LP"
import_block(block_scanner,lib_doc,doc)
import_block(block_separatoren,lib_doc,doc)
layer_scan, color_scan = get_insert_color_layer(lib_doc, block_scanner)
layer_separatioren, color_separatioren = get_insert_color_layer(lib_doc, block_separatoren)
block_methoden.import_block(block_scanner,lib_doc,doc)
block_methoden.import_block(block_separatoren,lib_doc,doc)
layer_scan, color_scan = block_methoden.get_insert_color_layer(lib_doc, block_scanner)
layer_separatioren, color_separatioren = block_methoden.get_insert_color_layer(lib_doc, block_separatoren)
einsatz_zwischen =[ einsatz_fest[0],einsatz_fest[1],einsatz_fest[2]]
anzahl =0
while anzahl < separatoren:
@@ -1187,8 +988,8 @@ def handle_ils_2_0_kurve_angetrieben(msp, teileid, merkmale, x, y, doc, lib_doc,
kurvenrichtung = voerder_kurve.kurvenrichtung
rotation = voerder_kurve.drehung
blockname = (f"Vario_Kurve_{kurvenrichtung}_{kurvenwinkel}°_TEF_{antriebNebenStrecke}")
import_block(blockname,lib_doc,doc)
layer, color = get_insert_color_layer(lib_doc, blockname)
block_methoden.import_block(blockname,lib_doc,doc)
layer, color = block_methoden.get_insert_color_layer(lib_doc, blockname)
msp.add_blockref(blockname,(x,y,h_zwischen),dxfattribs={"rotation": rotation,"layer": layer, "color":color})
@@ -1201,7 +1002,7 @@ def handle_ils_2_0_kurve(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, sy
kurvenrichtung = merkmale.get("Kurvenrichtung")
kurvenwinkel =int(merkmale.get("Kurvenwinkel"))
blockname = (f"Kurve_{kurvenrichtung}_{kurvenwinkel}°_R500_Gefälle")
import_block(blockname,lib_doc,doc)
block_methoden.import_block(blockname,lib_doc,doc)
msp.add_blockref(blockname,(x,y,hz),dxfattribs={"rotation": rotation})
def handle_bt___beladung(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
@@ -1210,7 +1011,7 @@ def handle_bt___beladung(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, sy
rotation = bt_element.drehung
hight = bt_element.hoehe
blockname = "AN8"
import_block(blockname,lib_doc,doc)
block_methoden.import_block(blockname,lib_doc,doc)
msp.add_blockref(blockname,(x,y,hight),dxfattribs={"rotation": rotation})
def handle_bt___entladung(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
@@ -1219,7 +1020,7 @@ def handle_bt___entladung(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, s
rotation = bt_element.drehung
hight = bt_element.hoehe
blockname = "AN8"
import_block(blockname,lib_doc,doc)
block_methoden.import_block(blockname,lib_doc,doc)
msp.add_blockref(blockname,(x,y,hight),dxfattribs={"rotation": rotation})
@@ -1252,21 +1053,11 @@ def handle_omniflo(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols,
print(f"[WARN] Omniflo-Block '{blockname}' nicht in Bibliothek {lib_doc.filename}. Überspringe {teileid}.")
return
blockname = blockname
import_block(blockname, lib_doc, doc)
layer, color = get_insert_color_layer(lib_doc, omniflo_objekt.sivasnummer)
block_methoden.import_block(blockname, lib_doc, doc)
layer, color = block_methoden.get_insert_color_layer(lib_doc, omniflo_objekt.sivasnummer)
msp.add_blockref(blockname, (x, y,omniflo_objekt.hoehe), dxfattribs={"rotation": rotation,"layer": layer, "color": color})
def get_insert_color_layer(lib_doc, blockname):
"""Gibt den Layer und die Color für den Jeweiligen block in der Libary datei zurück"""
msp_lib = lib_doc.modelspace()
color = 0
layer = 0
for insert in msp_lib.query("INSERT"):
if insert.dxf.name == blockname:
color = insert.dxf.color
layer = insert.dxf.layer
return layer, color
def normalize_func_name(name):