diff --git a/lib/Elemente/Gefaehllestrecke.py b/lib/Elemente/Gefaehllestrecke.py index 4a92d84..c3edb90 100644 --- a/lib/Elemente/Gefaehllestrecke.py +++ b/lib/Elemente/Gefaehllestrecke.py @@ -1,8 +1,10 @@ from pydantic import BaseModel, Field, field_validator -import math +import re import plant2dxf +import math from ezdxf.math import Matrix44 +import block_methoden class Gefaellestrecke(BaseModel): @@ -22,7 +24,6 @@ class Gefaellestrecke(BaseModel): @classmethod def from_merkmale(cls, teileid: str, x: float, y: float, merkmale: dict) -> 'Gefaellestrecke': - h0 = float(merkmale.get("Höhe unten")) * 1000 h1 = float(merkmale.get("Höhe oben")) * 1000 laenge = float(merkmale.get("Länge in Meter")) * 1000 @@ -37,6 +38,79 @@ class Gefaellestrecke(BaseModel): anzahl_scanner = int(merkmale.get("Anzahl der Scanner")), anzahl_separatoren = int(merkmale.get("Anzahl der Separatoren")) ) + + 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 = block_methoden.import_block(block_Vario_Bogen_auf,lib_doc,doc) + ab_attrib = block_methoden.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) + block_methoden.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 hat_motor_umlenk_station (gefaelle_objekt, gefaellestrecke_nachbarn): hat_motor_0 = None hat_motor_1 = None @@ -52,7 +126,6 @@ class Gefaellestrecke(BaseModel): x = gefaelle_objekt.x y = gefaelle_objekt.y - if "Kurvenrichtung" in gefaellestrecke_nachbarn: vario_hoehe_0 = float(gefaellestrecke_nachbarn.get("vario_hoehe_0")) vario_hoehe_1 = float(gefaellestrecke_nachbarn.get("vario_hoehe_1")) diff --git a/lib/Elemente/Kreisel.py b/lib/Elemente/Kreisel.py index 09752fb..bd1ff0f 100644 --- a/lib/Elemente/Kreisel.py +++ b/lib/Elemente/Kreisel.py @@ -4,6 +4,7 @@ import math from pydantic import BaseModel, Field, field_validator from typing import Optional import plant2dxf +import block_methoden ATTR_TAG = "TeileId" # Attributtag im Block @@ -218,8 +219,8 @@ class Kreisel(BaseModel): rotation = math.degrees(math.atan2(p2_oben[1] - p1_oben[1], p2_oben[0] - p1_oben[0])) if drehrichtung == "GUZS": rotation += 180 - plant2dxf.import_block("Richtungspfeil", lib_doc, doc) - blockref_layer, color = plant2dxf.get_insert_color_layer(lib_doc, "Richtungspfeil") + block_methoden.import_block("Richtungspfeil", lib_doc, doc) + blockref_layer, color = block_methoden.get_insert_color_layer(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}") @@ -231,8 +232,8 @@ class Kreisel(BaseModel): rotation = math.degrees(math.atan2(p2_unten[1] - p1_unten[1], p2_unten[0] - p1_unten[0])) if drehrichtung == "UZS": rotation += 180 - plant2dxf.import_block("Richtungspfeil", lib_doc, doc) - blockref_layer, color = plant2dxf.get_insert_color_layer( lib_doc, "Richtungspfeil") + block_methoden.import_block("Richtungspfeil", lib_doc, doc) + blockref_layer, color = block_methoden.get_insert_color_layer( 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}") \ No newline at end of file diff --git a/lib/Elemente/Omniflo.py b/lib/Elemente/Omniflo.py index cbf1798..8dc81f6 100644 --- a/lib/Elemente/Omniflo.py +++ b/lib/Elemente/Omniflo.py @@ -4,6 +4,7 @@ import math from pydantic import BaseModel, Field, field_validator from typing import Optional import plant2dxf +import block_methoden class Omniflo(BaseModel): teileid:str x:float @@ -68,8 +69,8 @@ class Omniflo(BaseModel): else: linie.dxf.layer = "A-2" def omniflo_foerdererstellung(msp, x, y, doc, lib_doc, omniflo_objekt, rotation): - plant2dxf.import_block("bogen1",lib_doc,doc) - plant2dxf.import_block("bogen2",lib_doc,doc) + block_methoden.import_block("bogen1",lib_doc,doc) + block_methoden.import_block("bogen2",lib_doc,doc) laenge = omniflo_objekt.laenge h0 = omniflo_objekt.h0 diff --git a/lib/Elemente/VarioFoerderer.py b/lib/Elemente/VarioFoerderer.py index 725b334..b083bb9 100644 --- a/lib/Elemente/VarioFoerderer.py +++ b/lib/Elemente/VarioFoerderer.py @@ -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 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 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 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) \ No newline at end of file diff --git a/lib/plant2dxf.py b/lib/plant2dxf.py index 092322c..f4fd245 100644 --- a/lib/plant2dxf.py +++ b/lib/plant2dxf.py @@ -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):