From 67aed63507a3f17d34ebe1dff478277022b85f76 Mon Sep 17 00:00:00 2001
From: Paul Wolok
Date: Tue, 2 Sep 2025 10:39:06 +0200
Subject: [PATCH] =?UTF-8?q?Pfadprobleme=20entfernt=20und=20erste=20wieder?=
=?UTF-8?q?=20lauff=C3=A4hige=20version=20erstellt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/plant2dxf.py | 48 +++++++++++++++++++++++++++---------------------
1 file changed, 27 insertions(+), 21 deletions(-)
diff --git a/lib/plant2dxf.py b/lib/plant2dxf.py
index 3fc2f4f..fcea5a3 100644
--- a/lib/plant2dxf.py
+++ b/lib/plant2dxf.py
@@ -347,26 +347,7 @@ def main(csv_path: Path, lib_path: Path, cfg_path: Path,
output_path: Path, verbose=False, logger=None):
# Bibliothek nur laden, wenn Datei existiert
- lib_doc = None
- if lib_path.exists():
- try:
- lib_doc = ezdxf.readfile(lib_path)
- if verbose:
- logger.info(f"[INFO] Bibliothek geladen: {lib_path}") if logger else print(f"[INFO] Bibliothek geladen: {lib_path}")
- except Exception as e:
- msg = f"Fehler beim Lesen der Bibliothek '{lib_path}': {e}"
- if logger:
- logger.error(msg)
- else:
- print(msg)
- sys.exit(1)
- else:
- msg = f"[INFO] Keine Bibliothek gefunden unter {lib_path}."
- if logger:
- logger.warning(msg)
- else:
- print(msg)
- sys.exit(1)
+ check_dxflibrary_path(lib_path, verbose, logger)
# Neue Zielzeichnung (DXF R2018)
doc = ezdxf.new(dxfversion="R2018")
@@ -383,6 +364,9 @@ def main(csv_path: Path, lib_path: Path, cfg_path: Path,
print(msg)
sys.exit(1)
+ blocklib_dir = data_dir / "block_libraries"
+ lib_docs = dict()
+
# Verarbeitung der Blöcke
with csv_path.open(newline="", encoding="utf-8") as fh:
reader = csv.DictReader(fh, delimiter=';')
@@ -428,7 +412,7 @@ def main(csv_path: Path, lib_path: Path, cfg_path: Path,
# Funktions-Dispatch: handle_ (mit _ statt Leerzeichen und Punkten, alles klein)
func_name = f'handle_{normalize_func_name(teileart)}'
handler = globals().get(func_name)
- symbols = get_shape_cfg(teileart, shapes_cfg_path, logger=logger)
+ symbols = get_shape_cfg(teileart, cfg_path, logger=logger)
# Mapping für Omniflo-Typen
if func_name.startswith('handle_omniflo'):
handler = globals().get('handle_omniflo')
@@ -449,6 +433,28 @@ def main(csv_path: Path, lib_path: Path, cfg_path: Path,
else:
print(f"[DONE] DXF gespeichert unter: {output_path}")
+def check_dxflibrary_path(lib_path, verbose, logger):
+ lib_doc = None
+ if lib_path.exists():
+ try:
+ lib_doc = ezdxf.readfile(lib_path)
+ if verbose:
+ logger.info(f"[INFO] Bibliothek geladen: {lib_path}") if logger else print(f"[INFO] Bibliothek geladen: {lib_path}")
+ except Exception as e:
+ msg = f"Fehler beim Lesen der Bibliothek '{lib_path}': {e}"
+ if logger:
+ logger.error(msg)
+ else:
+ print(msg)
+ sys.exit(1)
+ else:
+ msg = f"[INFO] Keine Bibliothek gefunden unter {lib_path}."
+ if logger:
+ logger.error(msg)
+ else:
+ print(msg)
+ sys.exit(1)
+
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Plaziert Anlagenkomponenten aus RuleDesigner CSV.")