doc ergänzt

This commit is contained in:
2026-06-16 17:42:14 +02:00
parent a11d0807d2
commit c650ea9b7c
2 changed files with 17 additions and 6 deletions
+16 -6
View File
@@ -49,6 +49,7 @@ import os
import sys
import ezdxf
from ezdxf import bbox
from ezdxf.enums import TextEntityAlignment
@@ -177,8 +178,7 @@ def build_lookup(boegen, weichen):
# ATTDEF zu DXF hinzufuegen
# ---------------------------------------------------------------------------
ATTDEF_START_Y = -50.0
ATTDEF_SPACING = -30.0
ATTDEF_SPACING = -8.0 # Delta Y zwischen Attributzeilen
ATTDEF_HEIGHT = 5.0
ATTDEF_LAYER = "ATTRIB"
@@ -246,13 +246,23 @@ def add_attdefs_to_dxf(dxf_path, output_path, attr_defs, json_entry, sivasnr,
for e in existing:
msp.delete_entity(e)
# Bounding Box der Geometrie berechnen (ohne ATTDEFs)
geo_entities = [e for e in msp if e.dxftype() != "ATTDEF"]
extents = bbox.extents(geo_entities)
if extents.has_data:
x_center = (extents.extmin.x + extents.extmax.x) / 2.0
y_start = extents.extmin.y + ATTDEF_SPACING
else:
x_center = 0.0
y_start = -50.0
# Alle ATTDEFs sammeln: Config-Attribute + LAYER aus [layer]-Sektion
all_defs = list(attr_defs)
if layer_value:
all_defs.append(("LAYER", f'"{layer_value}"'))
# ATTDEFs hinzufuegen
y_pos = ATTDEF_START_Y
# ATTDEFs hinzufuegen (zentriert unter der Geometrie)
y_pos = y_start
count = 0
for tag, source in all_defs:
default_value = resolve_value(source, json_entry, sivasnr)
@@ -261,12 +271,12 @@ def add_attdefs_to_dxf(dxf_path, output_path, attr_defs, json_entry, sivasnr,
msp.add_attdef(
tag=tag,
text=default_value,
insert=(x_center, y_pos),
dxfattribs={
"layer": ATTDEF_LAYER,
"height": ATTDEF_HEIGHT,
"insert": (0, y_pos),
"prompt": prompt,
"flags": 3, # unsichtbar (1) + konstant (2)
"flags": 1, # unsichtbar (1), nicht konstant -> erzeugt ATTRIB-Entities beim INSERT
},
)
y_pos += ATTDEF_SPACING