This commit is contained in:
2025-09-05 13:19:55 +02:00
2 changed files with 29 additions and 12 deletions
+8 -1
View File
@@ -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"])
+21 -11
View File
@@ -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:
@@ -327,13 +329,19 @@ def handle_omniflo(msp, teileid, merkmale, x, y, doc, lib_doc, verbose, symbols)
imported_block = doc.blocks.get(blockname)
if hasattr(lib_block.block.dxf, "base_point"):
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")})
else:
bref = msp.add_blockref(blockname, (x, y), dxfattribs={"xscale": 1.0, "yscale":1.0,"rotation": merkmale.get("Drehung")+180})
drehung = merkmale.get("Drehung")
if drehung not in (0.0, 180.0):
drehung = drehung -180
bref = msp.add_blockref(blockname, (x, y), dxfattribs={"xscale": 1.0, "yscale":1.0,"rotation": drehung })
bref.add_attrib(
tag= "NAME",
text= merkmale.get("bezeichner"),
insert = (x,y),
invisible =True
)
bref.add_auto_attribs({ATTR_TAG: teileid})
if verbose:
print(f"[INFO] Block '{blockname}' (Omniflo) → {teileid} ({x:.1f}, {y:.1f})")
@@ -391,10 +399,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)