Man kann jetzt Text sehen, falls irgenwas nicht passt zu dem letzten Springen

This commit is contained in:
2026-01-26 13:22:40 +01:00
parent d8f75450a9
commit c356b24fe9
2 changed files with 701 additions and 622 deletions
File diff suppressed because it is too large Load Diff
+52 -3
View File
@@ -26,7 +26,7 @@ def create_block_library(input_dir, output_file, config, logger=None):
logger: Optionaler Logger für Logging-Ausgaben
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
- Erstellt eine Log-Datei mit Zeitstempel für fehlerhafte Dateien
- Automatische Erstellung des Output-Verzeichnisses falls nötig
@@ -64,6 +64,8 @@ def create_block_library(input_dir, output_file, config, logger=None):
"ARC",
"INSERT",
"ATTDEF",
"TEXT",
"MTEXT",
"3DFACE",
"MESH",
"POLYFACE",
@@ -260,7 +262,7 @@ def copy_entity(logger, error_files, filename, e, center):
# Ursprungs-Layer übernehmen
if hasattr(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
return cp
@@ -556,10 +558,57 @@ def get_entity_bounding_box(e, doc,src_doc,filename,config, transform_matrix=Non
bbox.extend(sampled)
elif e.dxftype() == 'ATTDEF':
# Vereinfachung: Nur Insert-Point berücksichtigen
insert_point = Vec3(e.dxf.insert)
if transform_matrix:
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':
# Region: Begrenzungsgeometrie über virtual_entities()