Erweiterung der Kommandozeilenargumente in dxf2lib.py, um den Bibliotheksnamen optional zu machen und Eingabeaufforderung bei fehlendem Namen hinzuzufügen. Anpassung der Textplatzierung in svg2dxf.py, um längere Namen auf zwei Zeilen darzustellen und Fehlerbehandlung bei der Inkscape-Konvertierung zu integrieren.

This commit is contained in:
2025-07-29 15:29:36 +02:00
parent 4075cef30e
commit 91fffadc1f
2 changed files with 39 additions and 12 deletions
+13 -9
View File
@@ -2,7 +2,7 @@ import os
import subprocess
import sys
import argparse
import time
# Hilfsfunktion wie in plant2dxf.py
def check_environment_var(env_str: str, fallback: str) -> str:
@@ -44,16 +44,20 @@ if __name__ == "__main__":
os.makedirs(OUTPUT_DIR, exist_ok=True)
for filename in os.listdir(INPUT_DIR):
if filename.lower().endswith((".svg", ".xml")):
in_path = os.path.join(INPUT_DIR, filename)
name_wo_ext = os.path.splitext(filename)[0]
out_path = os.path.join(OUTPUT_DIR, name_wo_ext + ".dxf")
files = [f for f in os.listdir(INPUT_DIR) if f.lower().endswith((".svg", ".xml"))]
print(f"Konvertiere: {filename}{out_path}")
for filename in files:
input_path = os.path.join(INPUT_DIR, filename)
output_path = os.path.join(OUTPUT_DIR, os.path.splitext(filename)[0] + ".dxf")
print(f"Konvertiere: {input_path}{output_path}")
try:
subprocess.run([
INKSCAPE,
in_path,
input_path,
"--export-type=dxf",
f"--export-filename={out_path}"
f"--export-filename={output_path}"
], check=True)
except subprocess.CalledProcessError as e:
print(f"[FEHLER] Inkscape-Absturz bei {filename}: {e}")
time.sleep(0.5) # kleine Pause zur Entlastung von RAM/GTK