From 43b2ff35afb60fcb9dc3029e1e00ac1311156b8c Mon Sep 17 00:00:00 2001
From: Paul Wolok
Date: Thu, 4 Sep 2025 16:36:24 +0200
Subject: [PATCH] =?UTF-8?q?einf=C3=BCgen=20von=20einem=20eigennamen=20f?=
=?UTF-8?q?=C3=BCr=20die=20Bl=C3=B6cke?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/dxf2lib.py | 9 ++++++++-
lib/plant2dxf.py | 25 +++++++++++++++++--------
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/lib/dxf2lib.py b/lib/dxf2lib.py
index 5690275..1ab0f22 100644
--- a/lib/dxf2lib.py
+++ b/lib/dxf2lib.py
@@ -179,9 +179,16 @@ def create_block_library(input_dir, output_file, config, logger=None):
error_files.append((filename, error_msg))
# Platzierung in Reihen und Spalten
+ # Attribut-Definition (ATTDEF) hinzufügen
+ blk.add_attdef(
+ tag="NAME",
+ insert=(0.2, 0.2), # Position relativ zum Blockursprung
+ height=0.25,
+ text="Default Text"
+ )
msp.add_blockref(name, insert=(x_offset, y_offset))
# Text mit Blocknamen über dem Block
-
+
# Werte aus Config holen (Block: [dxf2lib])
section = "dxf2lib"
text_height = get_cfg_value(section, "text_height", DEFAULTS["text_height"])
diff --git a/lib/plant2dxf.py b/lib/plant2dxf.py
index b582829..e0bf2c8 100644
--- a/lib/plant2dxf.py
+++ b/lib/plant2dxf.py
@@ -269,12 +269,15 @@ def handle_ils_2_0_gefaellestrecke(msp, teileid, merkmale, x, y, doc, lib_doc, v
blockname = sym["name"]
offset = sym["offset"]
rotation = sym["rotation"]
- pos = (start[0] + offset[0], start[1] + offset[1]) if i == 0 else (ende[0] + offset[0], ende[1] + offset[1])
+ pos = (start[0] + offset[0], start[1] + offset[1]
+ ) if i == 0 else (ende[0] + offset[0], ende[1] + offset[1])
import_block(blockname, lib_doc, doc)
- bref = msp.add_blockref(blockname, pos, dxfattribs={"rotation": rotation})
+ bref = msp.add_blockref(blockname, pos, dxfattribs={
+ "rotation": rotation})
bref.add_auto_attribs({ATTR_TAG: teileid})
if verbose:
- print(f"[INFO] Block '{blockname}' an {'Startpunkt' if i==0 else 'Endpunkt'} {pos} für {teileid}, rot={rotation}")
+ print(
+ f"[INFO] Block '{blockname}' an {'Startpunkt' if i == 0 else 'Endpunkt'} {pos} für {teileid}, rot={rotation}")
elif lib_doc is None:
print("[WARN] lib_doc nicht verfügbar, Blöcke werden nicht eingefügt.")
@@ -308,8 +311,7 @@ def handle_omniflo(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols)
print(f"[INFO] Omniflo Gerade → {teileid} Linie von ({start[0]:.1f}, {start[1]:.1f}) nach ({ende[0]:.1f}, {ende[1]:.1f})")
return
# Sonst wie gehabt: Block mit SivasNummer
- if merkmale.get("Radius") is not None:
- r= float(merkmale.get("Radius"))
+
if not lib_doc:
@@ -329,11 +331,16 @@ def handle_omniflo(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols)
imported_block.block.dxf.base_point = lib_block.block.dxf.base_point
if merkmale.get("Drehung")== 0:
- bref = msp.add_blockref(blockname, (x, y), dxfattribs={"xscale": 1.0, "yscale":1.0,"rotation": merkmale.get("Drehung")})
+ bref = msp.add_blockref(blockname, (x-16.28, y), dxfattribs={"xscale": 1.0, "yscale":1.0,"rotation": merkmale.get("Drehung") })
else:
- bref = msp.add_blockref(blockname, (x, y), dxfattribs={"xscale": 1.0, "yscale":1.0,"rotation": merkmale.get("Drehung")+180})
-
+ bref = msp.add_blockref(blockname, (x-16.28, y), dxfattribs={
+ "xscale": 1.0, "yscale": 1.0, "rotation": merkmale.get("Drehung") - 180})
+ bref.add_attrib(
+ tag= "NAME",
+ text= "Hallo Welt"
+
+ )
bref.add_auto_attribs({ATTR_TAG: teileid})
if verbose:
print(f"[INFO] Block '{blockname}' (Omniflo) → {teileid} ({x:.1f}, {y:.1f})")
@@ -391,10 +398,12 @@ def main(csv_path: Path, lib_path: Path, cfg_path: Path,
with csv_path.open(newline="", encoding="utf-8") as fh:
reader = csv.DictReader(fh, delimiter=';')
for row in reader:
+ bezeichner = row["Bezeichnung"].strip()
teileart = row["TeileArt"].strip()
teileid = row["TeileId"].strip()
planquadrat = row["Planquadrat"]
merkmale = parse_merkmale(row.get("Merkmale", ""))
+ merkmale["bezeichner"] = bezeichner
try:
x_screen, y_screen = extract_coords(planquadrat)