Änderung paar Umvormulierungen zusatz von paar Kommentarten

This commit is contained in:
2026-01-21 11:09:08 +01:00
parent e67935ac6f
commit 212ec79ce8
2 changed files with 66 additions and 73 deletions
+47 -61
View File
@@ -17,7 +17,6 @@ from Elemente import Kreisel, VarioFoerderer,Gefaehllestrecke,Angetriebene_Kurve
import as_es_methoden
import block_methoden
import arbeiten_mit_csv
# --------------------------------------------------------- Konstante Parameter
ATTR_TAG = "TeileId" # Attributtag im Block
RADIUS = 400 # Radius der Kreiselkreise (mm)
@@ -102,7 +101,6 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
lower_hoehe_gefaehlle = gefaelle_objekt.h0
hoehe_gefaehlle = gefaelle_objekt.hight_zwischen
laenge = gefaelle_objekt.laenge
halbe_laenge = laenge / 2
rotation= gefaelle_objekt.drehung
winkel = math.radians(float(rotation))
@@ -179,7 +177,6 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
start = [x , y + dy ,upper_hoehe_gefaehlle]
ende = [x , y - dy ,lower_hoehe_gefaehlle]
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)
block.add_entity(line)
@@ -229,9 +226,8 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
as_es_rotation= 0
else:
as_es_rotation= -180
# Fügt as oder es Element ein oder fügt nur as oder es element hinzu falls nötig
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,None,as_es_rotation)
if only_es_or_as == False:
bref =msp.add_blockref(blockname,(x,y,hoehe_gefaehlle),dxfattribs={"rotation": rotation,"layer": gefaelle_layer})
a =bref.add_attrib(
@@ -351,51 +347,6 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
msp.add_blockref(blockname,(x,y,hoehe_gefaehlle),dxfattribs={"rotation": rotation,"layer": gefaelle_layer})
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
scanner = klassen_objekt.anzahl_scanner
# Schauen welche Ausrichtung das Objekt hat, damit man die Separtoren unbd Scanner nicht in das Objekt tut
if rotation == 0 or rotation == -180:
ausrichtung = "V"
else:
ausrichtung = "H"
if ausrichtung == "V":
einsatz_fest = [x + 300, y,hoehe]
modular = 2
else:
einsatz_fest = [x,y - 150,hoehe]
modular = 3
block_scanner = "SCAN"
block_separatoren = "S-LP"
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:
anzahl = anzahl + 1
msp.add_blockref(block_separatoren,einsatz_zwischen, dxfattribs={"layer": layer_separatioren,"color": color_separatioren})
if anzahl % modular == 0:
einsatz_fest[1] = einsatz_fest[1] - 150
einsatz_zwischen = einsatz_fest.copy()
else:
einsatz_zwischen[0] = einsatz_zwischen[0]+ 300
if anzahl % modular != 0:
einsatz_fest[1] = einsatz_fest[1] - 150
einsatz_zwischen = einsatz_fest.copy()
anzahl =0
while anzahl < scanner:
anzahl = anzahl + 1
msp.add_blockref(block_scanner,einsatz_zwischen,dxfattribs={"layer": layer_scan,"color": color_scan})
if anzahl % modular == 0:
einsatz_fest[1] = einsatz_fest[1] - 150
einsatz_zwischen = einsatz_fest.copy()
else:
einsatz_zwischen[0] = einsatz_zwischen[0]+ 300
def handle_ils_2_0_variofoerderer(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
"""Erstellt ein Vario Förderer in der neuen Dxf"""
@@ -435,8 +386,6 @@ def handle_ils_2_0_variofoerderer(msp, teileid, merkmale, x, y, doc, lib_doc, ve
# Korrektur der rotation mit der Umstellung der Höhe
rotation = rotation -180
foerderer.drehung = rotation
# Hollen der Information der Nachbarn strukturen ob diese Kreisel sind
for nachbarn in strecken_nachbarn:
if teileid == nachbarn.get("Id"):
@@ -450,6 +399,7 @@ def handle_ils_2_0_variofoerderer(msp, teileid, merkmale, x, y, doc, lib_doc, ve
# Für spätere berechnung schauen ob der erste Kreis in der Liste höher ist
if upper_hoehe_vario == gefaellestrecke_vario.get("Hoehe0"):
ein_kreisel_höher = True
# Falls der Förderer mit einem Eckrad verbunden ist
if "Eckrad_x" in gefaellestrecke_vario and "Eckrad_x_1" not in gefaellestrecke_vario:
x0_eckrad = gefaellestrecke_vario.get("Eckrad_x")
y0_eckrad = gefaellestrecke_vario.get("Eckrad_y")
@@ -476,6 +426,7 @@ def handle_ils_2_0_variofoerderer(msp, teileid, merkmale, x, y, doc, lib_doc, ve
elif merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
# Falls der Förderer mit zwei Eckrads verbunden ist
if "Eckrad_x" in gefaellestrecke_vario and "Eckrad_x_1" in gefaellestrecke_vario:
blockname = (f"Vario_Foerderer_{winkel}_{voerder_richtung}_{laenge}_{hoehe_vario}_rechts_2_{motor_vorhanden}_{umlenk_vorhanden}_{gefaelle}_{gefahellewinkel}")
@@ -496,7 +447,6 @@ def handle_ils_2_0_variofoerderer(msp, teileid, merkmale, x, y, doc, lib_doc, ve
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
# Aufruf falls nur mit einem Kreisel verbunden
if "Drehung0" in gefaellestrecke_vario and "Drehung1" not in gefaellestrecke_vario:
# Vorbereitund der Daten des Kreisel
@@ -511,9 +461,7 @@ def handle_ils_2_0_variofoerderer(msp, teileid, merkmale, x, y, doc, lib_doc, ve
y0_kreisel = float(gefaellestrecke_vario.get("y0"))
richtung0 = float(gefaellestrecke_vario.get("rotation0"))
richtung_rad0= math.radians(richtung0)
# Herausfinden ob der Förderere direkt mit dem Kreisel verbunden ist, die Werte für den Zweiten Kreisel wird auf None gesetzt weil diese nicht existieren
# None als string für späteren vergleich
mit_horizontal_verbunden = VarioFoerderer.VarioFoerderer.horizontale_ausrichtung(x, y, voerder_richtung, rotation, x0_kreisel, y0_kreisel)
am_kreisel,kreseil_verbunden =as_es_methoden.am_kreisel_direct_verbunden(x, y, upper_hoehe_vario, lower_hoehe_vario, x0_kreisel, y0_kreisel, richtung_rad0, abstand0, dx, dy, None, None, None, None )
if am_kreisel == 1:
@@ -536,7 +484,6 @@ def handle_ils_2_0_variofoerderer(msp, teileid, merkmale, x, y, doc, lib_doc, ve
# Erstellung einer Gefällestrecke von 500 mm in der Vario rein, wo es verbunden ist
start, ende = VarioFoerderer.VarioFoerderer.vario_verbuden_am_kreisel(foerderer, block_vario, start, ende, mit_horizontal_verbunden,kreseil_verbunden,am_kreisel,ein_kreisel_höher)
# Erstellung des Vario_förderes selber
VarioFoerderer.VarioFoerderer.vario_erstellung(foerderer, doc, lib_doc, config, block_vario,block_name_links, start, ende,voerder_richtung ,winkel_VP_offset_vorne,winkel_VP_offset_hinten)
# reintuen des förderes in den Modelspace
@@ -685,7 +632,6 @@ def handle_ils_2_0_variofoerderer(msp, teileid, merkmale, x, y, doc, lib_doc, ve
elif merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
return
# Erstellung des Blocks und diesen in die Modelspace tuen. Die Linke version wird bei der vario erstellung selber am ende gemacht
block_vario = doc.blocks.new(blockname, base_point=(0,0,0))
# Schauen welche es oder as element man braucht man braucht und diese in den block einfügen
@@ -732,8 +678,6 @@ def handle_ils_2_0_variofoerderer(msp, teileid, merkmale, x, y, doc, lib_doc, ve
if merkmale.get("Motorseite")== "rechts":
msp.add_blockref(blockname,(x,y,hoehe_vario),dxfattribs={"rotation": rotation})
def handle_ils_2_0_kurve_angetrieben(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
"""Erstellt eine Angetriebene Kurve (Förderer Kurve) in der neuen Dxf"""
voerder_kurve = Angetriebene_Kurve.Angetriebene_Kurve.from_merkmale(teileid,x,y,merkmale)
@@ -746,7 +690,6 @@ def handle_ils_2_0_kurve_angetrieben(msp, teileid, merkmale, x, y, doc, lib_doc,
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})
def handle_ils_2_0_kurve(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
"""Erstellt eine Kurve (Gefälle Kurve) in der neuen Dxf"""
@@ -778,7 +721,6 @@ def handle_bt___entladung(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, s
block_methoden.import_block(blockname,lib_doc,doc)
msp.add_blockref(blockname,(x,y,hight),dxfattribs={"rotation": rotation})
def handle_omniflo(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols, strecken_nachbarn,config,config_allgemein):
"""
Für Omniflo Gerade: zeichnet eine Linie (Mitte = Koordinate, Länge und Winkel aus Merkmale).
@@ -812,6 +754,50 @@ def handle_omniflo(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols,
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 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
scanner = klassen_objekt.anzahl_scanner
# Schauen welche Ausrichtung das Objekt hat, damit man die Separtoren unbd Scanner nicht in das Objekt tut
if rotation == 0 or rotation == -180:
ausrichtung = "V"
else:
ausrichtung = "H"
if ausrichtung == "V":
einsatz_fest = [x + 300, y,hoehe]
modular = 2
else:
einsatz_fest = [x,y - 150,hoehe]
modular = 3
block_scanner = "SCAN"
block_separatoren = "S-LP"
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:
anzahl = anzahl + 1
msp.add_blockref(block_separatoren,einsatz_zwischen, dxfattribs={"layer": layer_separatioren,"color": color_separatioren})
if anzahl % modular == 0:
einsatz_fest[1] = einsatz_fest[1] - 150
einsatz_zwischen = einsatz_fest.copy()
else:
einsatz_zwischen[0] = einsatz_zwischen[0]+ 300
if anzahl % modular != 0:
einsatz_fest[1] = einsatz_fest[1] - 150
einsatz_zwischen = einsatz_fest.copy()
anzahl =0
while anzahl < scanner:
anzahl = anzahl + 1
msp.add_blockref(block_scanner,einsatz_zwischen,dxfattribs={"layer": layer_scan,"color": color_scan})
if anzahl % modular == 0:
einsatz_fest[1] = einsatz_fest[1] - 150
einsatz_zwischen = einsatz_fest.copy()
else:
einsatz_zwischen[0] = einsatz_zwischen[0]+ 300
def get_libfile_cfg(teileart, cfg_path):
"""Liest den Bibliotheksdateinamen für eine TeileArt aus der allgemein.cfg."""
parser = configparser.ConfigParser()