Neue Skripte dxf2lib.py und svg2dxf.py hinzugefügt zur Verarbeitung von DXF-Dateien und zur Konvertierung von SVG in DXF.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Hilfsfunktion wie in plant2dxf.py
|
||||
|
||||
def check_environment_var(env_str: str, fallback: str) -> str:
|
||||
out_path = os.environ.get(env_str)
|
||||
if out_path:
|
||||
return out_path
|
||||
print(f"[WARN] Umgebungsvariable {env_str} ist nicht gesetzt oder leer. Verwende '{fallback}'.")
|
||||
return fallback
|
||||
|
||||
# Verzeichnisse über Umgebungsvariablen oder Fallback
|
||||
INPUT_DIR = os.path.join(check_environment_var("PROJECT_WORK", "."), "input_svg")
|
||||
OUTPUT_DIR = os.path.join(check_environment_var("PROJECT_WORK", "."), "converted_dxfs")
|
||||
INKSCAPE = "inkscape" # ggf. vollständiger Pfad angeben
|
||||
|
||||
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")
|
||||
|
||||
print(f"Konvertiere: {filename} → {out_path}")
|
||||
subprocess.run([
|
||||
INKSCAPE,
|
||||
in_path,
|
||||
"--export-type=dxf",
|
||||
f"--export-filename={out_path}"
|
||||
], check=True)
|
||||
Reference in New Issue
Block a user