Man kann jetzt Text sehen, falls irgenwas nicht passt zu dem letzten Springen
This commit is contained in:
File diff suppressed because it is too large
Load Diff
+55
-6
@@ -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",
|
||||
@@ -256,11 +258,11 @@ def copy_entity(logger, error_files, filename, e, center):
|
||||
try:
|
||||
cp = e.copy()
|
||||
# Geometrie verschieben!
|
||||
cp.translate(-center.x, -center.y,0)
|
||||
cp.translate(-center.x, -center.y, 0)
|
||||
# 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
|
||||
|
||||
@@ -406,7 +408,7 @@ def calculate_block_bounding_box(block, doc, src_doc, filename,config):
|
||||
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):
|
||||
@@ -556,11 +558,58 @@ 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()
|
||||
ve_bbox = _bbox_from_virtual_entities(
|
||||
|
||||
Reference in New Issue
Block a user