Merge branch 'main' of http://gitea.schoenenberger.de/mistangl/plant2dxf
This commit is contained in:
+6
-1
@@ -34,4 +34,9 @@ winkel_es = 3.0
|
|||||||
[Omniflo]
|
[Omniflo]
|
||||||
OFgeradesivas = 821106002
|
OFgeradesivas = 821106002
|
||||||
Tefgeradesivas = 0_B10030
|
Tefgeradesivas = 0_B10030
|
||||||
OFfoerderer = 2
|
OFfoerderer = 2
|
||||||
|
[Scanner_Stoper_namen]
|
||||||
|
Omniflo_stopper = 827062022
|
||||||
|
Omniflo_scanner = _DUMMY_SCANNER
|
||||||
|
ILS_scanner = SCAN
|
||||||
|
ILS_seperator = S-LP
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@ class Omniflo(BaseModel):
|
|||||||
h0: Optional[float] = Field(default = 0.0,description="Höhe unten im CSV")
|
h0: Optional[float] = Field(default = 0.0,description="Höhe unten im CSV")
|
||||||
h1: Optional[float] = Field(default = 0.0, description="Höhe Oben im CSV")
|
h1: Optional[float] = Field(default = 0.0, description="Höhe Oben im CSV")
|
||||||
anzahl_scanner: Optional [int] = Field(default=0, description="Anzahl der Scanner")
|
anzahl_scanner: Optional [int] = Field(default=0, description="Anzahl der Scanner")
|
||||||
anzahl_separatoren: Optional [int] = Field(default=0, description="Anzahl der Separatoren")
|
anzahl_stopper: Optional [int] = Field(default=0, description="Anzahl der Separatoren")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hight_zwischen(self):
|
def hight_zwischen(self):
|
||||||
@@ -45,11 +45,11 @@ class Omniflo(BaseModel):
|
|||||||
except Exception:
|
except Exception:
|
||||||
h1 = 0.0
|
h1 = 0.0
|
||||||
try:
|
try:
|
||||||
anzahl_scanner = int(merkmale.get("Anzahl der Scanner", "0").replace(",", ".")) * 1000 # Meter → mm
|
anzahl_scanner = float(merkmale.get("Anzahl der Scanner", "0"))
|
||||||
except Exception:
|
except Exception:
|
||||||
anzahl_scanner = 0
|
anzahl_scanner = 0
|
||||||
try:
|
try:
|
||||||
anzahl_separatoren = float(merkmale.get("Anzahl der Separatoren", "0").replace(",", ".")) * 1000 # Meter → mm
|
anzahl_separatoren = float(merkmale.get("Anzahl der Separatoren", "0"))
|
||||||
except Exception:
|
except Exception:
|
||||||
anzahl_separatoren = 0
|
anzahl_separatoren = 0
|
||||||
return cls(
|
return cls(
|
||||||
@@ -63,7 +63,7 @@ class Omniflo(BaseModel):
|
|||||||
h0 = h0,
|
h0 = h0,
|
||||||
h1 = h1,
|
h1 = h1,
|
||||||
anzahl_scanner = anzahl_scanner,
|
anzahl_scanner = anzahl_scanner,
|
||||||
anzahl_separatoren = anzahl_separatoren
|
anzahl_stopper = anzahl_separatoren
|
||||||
)
|
)
|
||||||
def Omniflo_geraden_erstellung(msp, doc, tefsivas, omniflo_objekt):
|
def Omniflo_geraden_erstellung(msp, doc, tefsivas, omniflo_objekt):
|
||||||
"""Erstellung der Tef gerade und Omniflo gerade"""
|
"""Erstellung der Tef gerade und Omniflo gerade"""
|
||||||
|
|||||||
+55
-6
@@ -26,7 +26,7 @@ def create_block_library(input_dir, output_file, config, logger=None):
|
|||||||
logger: Optionaler Logger für Logging-Ausgaben
|
logger: Optionaler Logger für Logging-Ausgaben
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
- Unterstützte Entity-Typen: LINE, LWPOLYLINE, POLYLINE, SPLINE, CIRCLE, ARC, INSERT, REGION, …
|
- Unterstützte Entity-Typen: LINE, LWPOLYLINE, POLYLINE, SPLINE, CIRCLE, ARC, INSERT, TEXT, MTEXT, REGION, …
|
||||||
- Blöcke werden zentriert und in einem 20x20 Raster angeordnet
|
- Blöcke werden zentriert und in einem 20x20 Raster angeordnet
|
||||||
- Erstellt eine Log-Datei mit Zeitstempel für fehlerhafte Dateien
|
- Erstellt eine Log-Datei mit Zeitstempel für fehlerhafte Dateien
|
||||||
- Automatische Erstellung des Output-Verzeichnisses falls nötig
|
- Automatische Erstellung des Output-Verzeichnisses falls nötig
|
||||||
@@ -64,6 +64,8 @@ def create_block_library(input_dir, output_file, config, logger=None):
|
|||||||
"ARC",
|
"ARC",
|
||||||
"INSERT",
|
"INSERT",
|
||||||
"ATTDEF",
|
"ATTDEF",
|
||||||
|
"TEXT",
|
||||||
|
"MTEXT",
|
||||||
"3DFACE",
|
"3DFACE",
|
||||||
"MESH",
|
"MESH",
|
||||||
"POLYFACE",
|
"POLYFACE",
|
||||||
@@ -256,11 +258,11 @@ def copy_entity(logger, error_files, filename, e, center):
|
|||||||
try:
|
try:
|
||||||
cp = e.copy()
|
cp = e.copy()
|
||||||
# Geometrie verschieben!
|
# Geometrie verschieben!
|
||||||
cp.translate(-center.x, -center.y,0)
|
cp.translate(-center.x, -center.y, 0)
|
||||||
# Ursprungs-Layer übernehmen
|
# Ursprungs-Layer übernehmen
|
||||||
if hasattr(e.dxf, "layer"):
|
if hasattr(e.dxf, "layer"):
|
||||||
cp.dxf.layer = e.dxf.layer
|
cp.dxf.layer = e.dxf.layer
|
||||||
if (hasattr(e.dxf, "color")):
|
if hasattr(e.dxf, "color"):
|
||||||
cp.dxf.color = e.dxf.color
|
cp.dxf.color = e.dxf.color
|
||||||
return cp
|
return cp
|
||||||
|
|
||||||
@@ -406,7 +408,7 @@ def calculate_block_bounding_box(block, doc, src_doc, filename,config):
|
|||||||
bbox.extend(entity_bbox)
|
bbox.extend(entity_bbox)
|
||||||
|
|
||||||
|
|
||||||
return bbox, (bbox.extmax.x -bbox.extmin.x, bbox.extmax.y -bbox.extmin.y),bbox.center
|
return bbox, (bbox.extmax.x - bbox.extmin.x, bbox.extmax.y - bbox.extmin.y), bbox.center
|
||||||
|
|
||||||
|
|
||||||
def _bbox_from_virtual_entities(entity, doc, src_doc, filename, config, transform_matrix=None):
|
def _bbox_from_virtual_entities(entity, doc, src_doc, filename, config, transform_matrix=None):
|
||||||
@@ -556,11 +558,58 @@ def get_entity_bounding_box(e, doc,src_doc,filename,config, transform_matrix=Non
|
|||||||
bbox.extend(sampled)
|
bbox.extend(sampled)
|
||||||
|
|
||||||
elif e.dxftype() == 'ATTDEF':
|
elif e.dxftype() == 'ATTDEF':
|
||||||
# Vereinfachung: Nur Insert-Point berücksichtigen
|
|
||||||
insert_point = Vec3(e.dxf.insert)
|
insert_point = Vec3(e.dxf.insert)
|
||||||
if transform_matrix:
|
if transform_matrix:
|
||||||
insert_point = transform_matrix.transform(insert_point)
|
insert_point = transform_matrix.transform(insert_point)
|
||||||
|
elif e.dxftype() == 'TEXT':
|
||||||
|
insert_point = Vec3(e.dxf.insert)
|
||||||
|
height = float(getattr(e.dxf, "height", 1.0))
|
||||||
|
width_factor = float(getattr(e.dxf, "width", 1.0))
|
||||||
|
rotation = math.radians(getattr(e.dxf, "rotation", 0.0))
|
||||||
|
text_content = getattr(e.dxf, "text", "") or ""
|
||||||
|
est_width = max(len(text_content) * height * 0.6 * width_factor, height * 0.5)
|
||||||
|
corners = [
|
||||||
|
insert_point,
|
||||||
|
insert_point + Vec3(est_width, 0, 0),
|
||||||
|
insert_point + Vec3(0, height, 0),
|
||||||
|
insert_point + Vec3(est_width, height, 0),
|
||||||
|
]
|
||||||
|
if rotation != 0:
|
||||||
|
cos_r, sin_r = math.cos(rotation), math.sin(rotation)
|
||||||
|
origin = insert_point
|
||||||
|
rotated = []
|
||||||
|
for c in corners:
|
||||||
|
dx, dy = c.x - origin.x, c.y - origin.y
|
||||||
|
rx = origin.x + dx * cos_r - dy * sin_r
|
||||||
|
ry = origin.y + dx * sin_r + dy * cos_r
|
||||||
|
rotated.append(Vec3(rx, ry, c.z))
|
||||||
|
corners = rotated
|
||||||
|
for pt in corners:
|
||||||
|
if transform_matrix:
|
||||||
|
pt = transform_matrix.transform(pt)
|
||||||
|
bbox.extend([pt])
|
||||||
|
|
||||||
|
elif e.dxftype() == 'MTEXT':
|
||||||
|
insert_point = Vec3(e.dxf.insert)
|
||||||
|
char_height = float(getattr(e.dxf, "char_height", 1.0))
|
||||||
|
width = float(getattr(e.dxf, "width", 0.0))
|
||||||
|
if width <= 0:
|
||||||
|
width = 10.0 * char_height
|
||||||
|
text_content = getattr(e.dxf, "text", "") or ""
|
||||||
|
lines = len(text_content.split("\n")) or 1
|
||||||
|
box_height = char_height * lines * 1.2
|
||||||
|
corners = [
|
||||||
|
insert_point,
|
||||||
|
insert_point + Vec3(width, 0, 0),
|
||||||
|
insert_point + Vec3(0, box_height, 0),
|
||||||
|
insert_point + Vec3(width, box_height, 0),
|
||||||
|
]
|
||||||
|
for pt in corners:
|
||||||
|
if transform_matrix:
|
||||||
|
pt = transform_matrix.transform(pt)
|
||||||
|
bbox.extend([pt])
|
||||||
|
|
||||||
elif e.dxftype() == 'REGION':
|
elif e.dxftype() == 'REGION':
|
||||||
# Region: Begrenzungsgeometrie über virtual_entities()
|
# Region: Begrenzungsgeometrie über virtual_entities()
|
||||||
ve_bbox = _bbox_from_virtual_entities(
|
ve_bbox = _bbox_from_virtual_entities(
|
||||||
|
|||||||
+58
-24
@@ -99,7 +99,7 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
|
|||||||
verbunden_am_einen = False
|
verbunden_am_einen = False
|
||||||
richtung2 ="DEFAULT"
|
richtung2 ="DEFAULT"
|
||||||
unterschiedlich = False
|
unterschiedlich = False
|
||||||
anzahl_seperatoren_oder_scan(msp, doc, lib_doc, gefaelle_objekt)
|
anzahl_seperatoren_oder_scan(msp, doc, lib_doc, gefaelle_objekt,config)
|
||||||
for nachbarn in strecken_nachbarn:
|
for nachbarn in strecken_nachbarn:
|
||||||
if teileid == nachbarn.get("Id"):
|
if teileid == nachbarn.get("Id"):
|
||||||
gefaellestrecke_nachbarn = nachbarn
|
gefaellestrecke_nachbarn = nachbarn
|
||||||
@@ -336,7 +336,7 @@ def handle_ils_2_0_variofoerderer(msp, teileid, merkmale, x, y, doc, lib_doc, ve
|
|||||||
upper_hoehe_vario= foerderer.h1
|
upper_hoehe_vario= foerderer.h1
|
||||||
lower_hoehe_vario = foerderer.h0
|
lower_hoehe_vario = foerderer.h0
|
||||||
hoehe_vario= foerderer.hight_zwischen
|
hoehe_vario= foerderer.hight_zwischen
|
||||||
anzahl_seperatoren_oder_scan(msp, doc, lib_doc, foerderer)
|
anzahl_seperatoren_oder_scan(msp, doc, lib_doc, foerderer,config)
|
||||||
as_es_methoden.vertausch_der_höhe(foerderer)
|
as_es_methoden.vertausch_der_höhe(foerderer)
|
||||||
upper_hoehe_vario = foerderer.h1
|
upper_hoehe_vario = foerderer.h1
|
||||||
lower_hoehe_vario = foerderer.h0
|
lower_hoehe_vario = foerderer.h0
|
||||||
@@ -690,7 +690,7 @@ def handle_omniflo(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols,
|
|||||||
if omniflo_objekt.sivasnummer == omnisivas or omniflo_objekt.sivasnummer == tefsivas:
|
if omniflo_objekt.sivasnummer == omnisivas or omniflo_objekt.sivasnummer == tefsivas:
|
||||||
Omniflo.Omniflo.Omniflo_geraden_erstellung(msp, doc, tefsivas, omniflo_objekt)
|
Omniflo.Omniflo.Omniflo_geraden_erstellung(msp, doc, tefsivas, omniflo_objekt)
|
||||||
if omniflo_objekt.sivasnummer == omnisivas:
|
if omniflo_objekt.sivasnummer == omnisivas:
|
||||||
anzahl_seperatoren_oder_scan(msp, doc, lib_doc, omniflo_objekt)
|
anzahl_seperatoren_oder_scan(msp, doc, lib_doc, omniflo_objekt,config)
|
||||||
elif omniflo_objekt.sivasnummer == foerderer:
|
elif omniflo_objekt.sivasnummer == foerderer:
|
||||||
Omniflo.Omniflo.omniflo_foerdererstellung(msp, doc, lib_doc, omniflo_objekt)
|
Omniflo.Omniflo.omniflo_foerdererstellung(msp, doc, lib_doc, omniflo_objekt)
|
||||||
return
|
return
|
||||||
@@ -711,14 +711,20 @@ 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)
|
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})
|
msp.add_blockref(blockname, (x, y,omniflo_objekt.hoehe), dxfattribs={"rotation": rotation,"layer": layer, "color": color})
|
||||||
|
|
||||||
def anzahl_seperatoren_oder_scan(msp, doc, lib_doc, klassen_objekt):
|
def anzahl_seperatoren_oder_scan(msp, doc, lib_doc, klassen_objekt,config):
|
||||||
"""Importiert alle seperatoren und/oder scanner für das nötige objekt"""
|
"""Importiert alle seperatoren und/oder scanner für das nötige objekt"""
|
||||||
separatoren = klassen_objekt.anzahl_separatoren
|
omniflo_scanner = config.get("Scanner_Stoper_namen","Omniflo_scanner")
|
||||||
|
ILS_scanner = config.get("Scanner_Stoper_namen","Ils_scanner")
|
||||||
|
omniflo_stopper = config.get("Scanner_Stoper_namen","Omniflo_stopper")
|
||||||
|
ILS_seperator = config.get("Scanner_Stoper_namen","ILS_seperator")
|
||||||
scanner = klassen_objekt.anzahl_scanner
|
scanner = klassen_objekt.anzahl_scanner
|
||||||
|
separatoren = None
|
||||||
|
stopper = None
|
||||||
x = klassen_objekt.x
|
x = klassen_objekt.x
|
||||||
y = klassen_objekt.y
|
y = klassen_objekt.y
|
||||||
hoehe =klassen_objekt.hight_zwischen
|
hoehe =klassen_objekt.hight_zwischen
|
||||||
rotation = klassen_objekt.drehung
|
rotation = klassen_objekt.drehung
|
||||||
|
|
||||||
# Schauen welche Ausrichtung das Objekt hat, damit man die Separtoren unbd Scanner nicht in das Objekt tut
|
# Schauen welche Ausrichtung das Objekt hat, damit man die Separtoren unbd Scanner nicht in das Objekt tut
|
||||||
if rotation == 0 or rotation == -180:
|
if rotation == 0 or rotation == -180:
|
||||||
ausrichtung = "V"
|
ausrichtung = "V"
|
||||||
@@ -730,30 +736,58 @@ def anzahl_seperatoren_oder_scan(msp, doc, lib_doc, klassen_objekt):
|
|||||||
else:
|
else:
|
||||||
einsatz_fest = [x,y - 150,hoehe]
|
einsatz_fest = [x,y - 150,hoehe]
|
||||||
modular = 3
|
modular = 3
|
||||||
block_scanner = "SCAN"
|
if omniflo_scanner not in lib_doc.blocks:
|
||||||
block_separatoren = "S-LP"
|
block_methoden.import_block(ILS_scanner,lib_doc,doc)
|
||||||
block_methoden.import_block(block_scanner,lib_doc,doc)
|
block_methoden.import_block(ILS_seperator,lib_doc,doc)
|
||||||
block_methoden.import_block(block_separatoren,lib_doc,doc)
|
scanner_name = ILS_scanner
|
||||||
layer_scan, color_scan = block_methoden.get_insert_color_layer(lib_doc, block_scanner)
|
separator_name = ILS_seperator
|
||||||
layer_separatioren, color_separatioren = block_methoden.get_insert_color_layer(lib_doc, block_separatoren)
|
layer_scan, color_scan = block_methoden.get_insert_color_layer(lib_doc, ILS_scanner)
|
||||||
|
layer_separatioren, color_separatioren = block_methoden.get_insert_color_layer(lib_doc, ILS_seperator)
|
||||||
|
separatoren = klassen_objekt.anzahl_separatoren
|
||||||
|
|
||||||
|
else:
|
||||||
|
block_methoden.import_block(omniflo_scanner,lib_doc,doc)
|
||||||
|
block_methoden.import_block(omniflo_stopper,lib_doc,doc)
|
||||||
|
scanner_name = omniflo_scanner
|
||||||
|
stopper_name = omniflo_stopper
|
||||||
|
layer_scan, color_scan = block_methoden.get_insert_color_layer(lib_doc, omniflo_scanner)
|
||||||
|
layer_stopper, color_stopper = block_methoden.get_insert_color_layer(lib_doc, omniflo_stopper)
|
||||||
|
stopper = klassen_objekt.anzahl_stopper
|
||||||
|
|
||||||
einsatz_zwischen =[ einsatz_fest[0],einsatz_fest[1],einsatz_fest[2]]
|
einsatz_zwischen =[ einsatz_fest[0],einsatz_fest[1],einsatz_fest[2]]
|
||||||
anzahl =0
|
anzahl =0
|
||||||
while anzahl < separatoren:
|
if separatoren != None:
|
||||||
anzahl = anzahl + 1
|
while anzahl < separatoren:
|
||||||
msp.add_blockref(block_separatoren,einsatz_zwischen, dxfattribs={"layer": layer_separatioren,"color": color_separatioren})
|
anzahl = anzahl + 1
|
||||||
if anzahl % modular == 0:
|
msp.add_blockref(separator_name,einsatz_zwischen, dxfattribs={"layer": layer_separatioren,"color": color_separatioren})
|
||||||
einsatz_fest[1] = einsatz_fest[1] - 150
|
if anzahl % modular == 0:
|
||||||
einsatz_zwischen = einsatz_fest.copy()
|
einsatz_fest[1] = einsatz_fest[1] - 150
|
||||||
else:
|
einsatz_zwischen = einsatz_fest.copy()
|
||||||
einsatz_zwischen[0] = einsatz_zwischen[0]+ 300
|
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
|
||||||
|
else:
|
||||||
|
while anzahl < stopper:
|
||||||
|
anzahl = anzahl + 1
|
||||||
|
msp.add_blockref(stopper_name,einsatz_zwischen, dxfattribs={"layer": layer_stopper,"color": color_stopper})
|
||||||
|
if anzahl % modular == 0:
|
||||||
|
einsatz_fest[1] = einsatz_fest[1] - 250
|
||||||
|
einsatz_zwischen = einsatz_fest.copy()
|
||||||
|
else:
|
||||||
|
einsatz_zwischen[0] = einsatz_zwischen[0]+ 200
|
||||||
|
|
||||||
|
if anzahl % modular != 0:
|
||||||
|
einsatz_fest[1] = einsatz_fest[1] - 250
|
||||||
|
einsatz_zwischen = einsatz_fest.copy()
|
||||||
|
anzahl =0
|
||||||
|
|
||||||
if anzahl % modular != 0:
|
|
||||||
einsatz_fest[1] = einsatz_fest[1] - 150
|
|
||||||
einsatz_zwischen = einsatz_fest.copy()
|
|
||||||
anzahl =0
|
|
||||||
while anzahl < scanner:
|
while anzahl < scanner:
|
||||||
anzahl = anzahl + 1
|
anzahl = anzahl + 1
|
||||||
msp.add_blockref(block_scanner,einsatz_zwischen,dxfattribs={"layer": layer_scan,"color": color_scan})
|
msp.add_blockref(scanner_name,einsatz_zwischen,dxfattribs={"layer": layer_scan,"color": color_scan})
|
||||||
if anzahl % modular == 0:
|
if anzahl % modular == 0:
|
||||||
einsatz_fest[1] = einsatz_fest[1] - 150
|
einsatz_fest[1] = einsatz_fest[1] - 150
|
||||||
einsatz_zwischen = einsatz_fest.copy()
|
einsatz_zwischen = einsatz_fest.copy()
|
||||||
|
|||||||
Reference in New Issue
Block a user