EXPORT für Sivas CSV und einfache Stückliste in je eigenem Menüpunkt aufrufbar
This commit is contained in:
+70
-3
@@ -111,12 +111,80 @@
|
||||
)
|
||||
)
|
||||
|
||||
;; --- Hauptfunktion: EXPORTCSV ---
|
||||
;; --- EXPORTSIVAS: Sivas-spezifischer CSV-Export mit Summierungszeilen ---
|
||||
(defun c:EXPORTSIVAS ( / ss i ename json-str out-pfad py-skript cmd fh
|
||||
ergebnis-pfad first-block count)
|
||||
(princ "\n[EXPORTSIVAS] Sammle alle Bloecke der Zeichnung...")
|
||||
|
||||
;; Alle INSERT-Entities in der Zeichnung
|
||||
(setq ss (ssget "X" (list (cons 0 "INSERT"))))
|
||||
(if (null ss)
|
||||
(progn
|
||||
(princ "\n[EXPORTSIVAS] Keine Bloecke in der Zeichnung gefunden.")
|
||||
(princ)
|
||||
)
|
||||
(progn
|
||||
(setq count (sslength ss))
|
||||
(princ (strcat "\n[EXPORTSIVAS] " (itoa count) " Bloecke gefunden."))
|
||||
|
||||
;; JSON-Datei zusammenbauen
|
||||
(setq out-pfad (strcat (getenv "DXFM_RESULTS") "/export_raw.json"))
|
||||
(setq fh (open out-pfad "w"))
|
||||
(if (null fh)
|
||||
(progn
|
||||
(princ (strcat "\n[EXPORTSIVAS] FEHLER: Kann Datei nicht oeffnen: " out-pfad))
|
||||
(princ)
|
||||
)
|
||||
(progn
|
||||
(write-line "[" fh)
|
||||
(setq i 0)
|
||||
(setq first-block T)
|
||||
(while (setq ename (ssname ss i))
|
||||
(if (not first-block)
|
||||
(write-line "," fh)
|
||||
)
|
||||
(setq json-str (csv:block-to-json ename))
|
||||
(write-line json-str fh)
|
||||
(setq first-block nil)
|
||||
(setq i (1+ i))
|
||||
)
|
||||
(write-line "]" fh)
|
||||
(close fh)
|
||||
(princ (strcat "\n[EXPORTSIVAS] JSON geschrieben: " out-pfad))
|
||||
|
||||
;; Python-Skript aufrufen
|
||||
(setq py-skript (strcat (getenv "DXFM_LIB") "/export_sivas.py"))
|
||||
(if (findfile py-skript)
|
||||
(progn
|
||||
(setq ergebnis-pfad (strcat (getenv "DXFM_RESULTS") "/export_sivas.csv"))
|
||||
(setq cmd (strcat "python \"" py-skript "\""
|
||||
" \"" out-pfad "\""
|
||||
" \"" (getenv "DXFM_DATA") "\""
|
||||
" \"" ergebnis-pfad "\""))
|
||||
(princ (strcat "\n[EXPORTSIVAS] Rufe Python auf..."))
|
||||
(command "_.SHELL" cmd)
|
||||
(if (findfile ergebnis-pfad)
|
||||
(princ (strcat "\n[EXPORTSIVAS] CSV erstellt: " ergebnis-pfad))
|
||||
(princ "\n[EXPORTSIVAS] WARNUNG: CSV-Datei wurde nicht erzeugt.")
|
||||
)
|
||||
)
|
||||
(princ (strcat "\n[EXPORTSIVAS] FEHLER: Python-Skript nicht gefunden: " py-skript))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(princ)
|
||||
)
|
||||
|
||||
|
||||
;; --- EXPORTCSV: Einfache Item-Liste aller Bloecke (ohne Summierung) ---
|
||||
;; Nutzt dieselben csv:* Hilfsfunktionen und export_raw.json,
|
||||
;; ruft export_csv.py auf fuer die einfache CSV-Erzeugung.
|
||||
(defun c:EXPORTCSV ( / ss i ename json-str out-pfad py-skript cmd fh
|
||||
ergebnis-pfad first-block count)
|
||||
(princ "\n[EXPORTCSV] Sammle alle Bloecke der Zeichnung...")
|
||||
|
||||
;; Alle INSERT-Entities in der Zeichnung
|
||||
(setq ss (ssget "X" (list (cons 0 "INSERT"))))
|
||||
(if (null ss)
|
||||
(progn
|
||||
@@ -127,7 +195,6 @@
|
||||
(setq count (sslength ss))
|
||||
(princ (strcat "\n[EXPORTCSV] " (itoa count) " Bloecke gefunden."))
|
||||
|
||||
;; JSON-Datei zusammenbauen
|
||||
(setq out-pfad (strcat (getenv "DXFM_RESULTS") "/export_raw.json"))
|
||||
(setq fh (open out-pfad "w"))
|
||||
(if (null fh)
|
||||
|
||||
Reference in New Issue
Block a user