Startup Skript in .lsp wird beim Starten des CAD mit aufgerufen, so dass die Menüs gebaut werden

This commit is contained in:
2026-05-07 15:53:34 +02:00
parent aac7d7c1bb
commit efa79745fa
4 changed files with 186 additions and 73 deletions
+109 -70
View File
@@ -46,11 +46,11 @@
(setq FESTE_HORIZONTAL 1600)
;; ============================================================
;; KONFIGURATION: Flag für dynamische BoundingBox-Berechnung
;; Setze auf t für dynamische Berechnung aus .dwg-Dateien
;; Setze auf nil für feste, hartkodierte Werte
;; KONFIGURATION: Flag fuer dynamische Bogen-Tabellen
;; t = dynamisch aus KS_EIN/KS_AUS der Koordinaten-Bibliothek
;; nil = feste, hartkodierte Werte (Fallback)
;; ============================================================
(setq use-dynamic-bbox nil) ;; Ändere hier: t = dynamisch, nil = hartkodiert
(setq use-dynamic-bbox t) ;; t = dynamisch, nil = hartkodiert
;; ============================================================
;; Feste, hartkodierte Bogen-Tabellen (Fallback)
@@ -101,74 +101,9 @@
)
)
;; ============================================================
;; Funktion zum Erstellen der Bogen-Tabellen dynamisch
;; ============================================================
(defun create-bogen-table (richtung unten-oben / winkel-list table bbox)
(setq winkel-list '(3 9 12 15 24 36 48))
(setq table '())
(foreach winkel winkel-list
(setq blockname (strcat modul-pfad "Vertikalbogen_" richtung "_" (itoa winkel) "_" unten-oben ".dwg"))
(setq bbox (get-block-bbox blockname))
(if (and (> (car bbox) 0) (> (caddr bbox) 0)) ;; Nur gültige Werte
(setq table (cons (cons winkel bbox) table))
(princ (strcat "\nWARNUNG: Ungültige BoundingBox für " blockname))
)
)
(reverse table)
)
;; ============================================================
;; TEIL 3: BOGEN-MASSE (Verzweigung basierend auf Flag)
;; ============================================================
(if use-dynamic-bbox
(progn
(princ "\nVerwende dynamische BoundingBox-Berechnung für Bogen-Tabellen...")
(if (null bogen-auf-unten)
(progn
(setq bogen-auf-unten (create-bogen-table "Auf" "Unten"))
(setq bogen-auf-oben (create-bogen-table "Auf" "Oben"))
(setq bogen-ab-oben (create-bogen-table "Ab" "Oben"))
(setq bogen-ab-unten (create-bogen-table "Ab" "Unten"))
(princ "\nDynamische Bogen-Tabellen initialisiert.")
)
)
)
(progn
(princ "\nVerwende hartkodierte Werte für Bogen-Tabellen...")
(setq bogen-auf-unten bogen-auf-unten-hardcoded)
(setq bogen-auf-oben bogen-auf-oben-hardcoded)
(setq bogen-ab-oben bogen-ab-oben-hardcoded)
(setq bogen-ab-unten bogen-ab-unten-hardcoded)
(princ "\nHartkodierte Bogen-Tabellen geladen.")
)
)
;; ============================================================
;; TEIL 4: HILFSFUNKTIONEN
;; ============================================================
(defun punkt-differenz (p1 p2)
(list (- (car p2) (car p1)) (- (cadr p2) (cadr p1)) (- (caddr p2) (caddr p1)))
)
(defun get-bogen-mass (tabelle winkel)
(setq result nil)
(foreach item tabelle (if (= (car item) winkel) (setq result (cdr item))))
(if (null result) (setq result '(800 0 0))) result
)
(defun get-bogen-mass-mit-abs (tabelle winkel)
(setq result nil)
(foreach item tabelle (if (= (car item) winkel) (setq result (list (cadr item) (caddr item) (abs (cadddr item))))))
(if (null result) (setq result '(800 0 0))) result
)
(defun fmt (x)
(if (and (numberp x) (not (equal x nil))) (rtos x 2 2) "---")
)
;; ============================================================
;; TEIL 4b: KS_EIN / KS_AUS KOORDINATEN EXTRAHIEREN
;; (vor create-bogen-table, da dort benoetigt)
;; ============================================================
;; Grad-Zeichen fuer Blocknamen
@@ -335,6 +270,110 @@
ks-results
)
;; ============================================================
;; Funktion zum Erstellen der Bogen-Tabellen dynamisch
;; Verwendet KS_EIN/KS_AUS aus der Koordinaten-Bibliothek
;; ============================================================
(defun create-bogen-table (richtung unten-oben / winkel-list table
bogen-name full-name block-obj ks-data
ks-ein-data ks-aus-data ein-origin aus-origin
dx dz richtung-klein)
(setq winkel-list '(3 9 12 15 24 36 48))
(setq table '())
;; Richtung kleingeschrieben fuer Blocknamen (Vario_Bogen_auf_3°)
(setq richtung-klein (if (= richtung "Auf") "auf" "ab"))
;; Koordinaten-Bibliothek laden
(load-koordinaten-lib)
(foreach winkel winkel-list
(setq bogen-name (strcat "Vario_Bogen_" richtung-klein "_" (itoa winkel)))
(setq full-name (strcat bogen-name grad-zeichen))
(if (tblsearch "BLOCK" full-name)
(progn
;; Block temporaer einfuegen bei (0,0,0)
(setq block-obj (vla-InsertBlock modelspace
(vlax-3D-point '(0 0 0))
full-name 1.0 1.0 1.0 0))
;; KS_EIN und KS_AUS extrahieren
(setq ks-data (extract-ks-from-block block-obj))
;; Block loeschen
(vla-Delete block-obj)
(setq ks-ein-data (cadr (assoc "KS_EIN" ks-data)))
(setq ks-aus-data (cadr (assoc "KS_AUS" ks-data)))
(if (and ks-ein-data ks-aus-data)
(progn
(setq ein-origin (car ks-ein-data))
(setq aus-origin (car ks-aus-data))
;; Offset: KS_AUS - KS_EIN
(setq dx (- (car aus-origin) (car ein-origin)))
(setq dz (- (caddr aus-origin) (caddr ein-origin)))
(princ (strcat "\n " full-name ": dx=" (rtos dx 2 2) " dz=" (rtos dz 2 2)))
(setq table (cons (list winkel dx 0 dz) table))
)
(princ (strcat "\nWARNUNG: KS_EIN/KS_AUS nicht gefunden in " full-name))
)
)
(princ (strcat "\nWARNUNG: Block " full-name " nicht in Bibliothek"))
)
)
(reverse table)
)
;; ============================================================
;; TEIL 3: BOGEN-MASSE (Verzweigung basierend auf Flag)
;; ============================================================
(if use-dynamic-bbox
(progn
(princ "\nVerwende dynamische KS_EIN/KS_AUS-Berechnung fuer Bogen-Tabellen...")
(if (null bogen-auf-unten)
(progn
(setq bogen-auf-unten (create-bogen-table "Auf" "Unten"))
(setq bogen-auf-oben (create-bogen-table "Auf" "Oben"))
(setq bogen-ab-oben (create-bogen-table "Ab" "Oben"))
(setq bogen-ab-unten (create-bogen-table "Ab" "Unten"))
(princ "\nDynamische Bogen-Tabellen initialisiert.")
)
)
)
(progn
(princ "\nVerwende hartkodierte Werte fuer Bogen-Tabellen...")
(setq bogen-auf-unten bogen-auf-unten-hardcoded)
(setq bogen-auf-oben bogen-auf-oben-hardcoded)
(setq bogen-ab-oben bogen-ab-oben-hardcoded)
(setq bogen-ab-unten bogen-ab-unten-hardcoded)
(princ "\nHartkodierte Bogen-Tabellen geladen.")
)
)
;; ============================================================
;; TEIL 4: HILFSFUNKTIONEN
;; ============================================================
(defun punkt-differenz (p1 p2)
(list (- (car p2) (car p1)) (- (cadr p2) (cadr p1)) (- (caddr p2) (caddr p1)))
)
(defun get-bogen-mass (tabelle winkel)
(setq result nil)
(foreach item tabelle (if (= (car item) winkel) (setq result (cdr item))))
(if (null result) (setq result '(800 0 0))) result
)
(defun get-bogen-mass-mit-abs (tabelle winkel)
(setq result nil)
(foreach item tabelle (if (= (car item) winkel) (setq result (list (cadr item) (caddr item) (abs (cadddr item))))))
(if (null result) (setq result '(800 0 0))) result
)
(defun fmt (x)
(if (and (numberp x) (not (equal x nil))) (rtos x 2 2) "---")
)
;; (TEIL 4b wurde nach oben verschoben, vor create-bogen-table)
;; Bogen-Block aus der Koordinaten-Bibliothek einfuegen und KS-Daten extrahieren.
;; bogen-name = Blockname ohne Grad-Zeichen (z.B. "Vario_Bogen_auf_3")
;; einfuege-punkt = Punkt an dem der Block eingefuegt wird
+74
View File
@@ -0,0 +1,74 @@
;; ============================================================
;; on_start.lsp - SSG_LIB Startup fuer BricsCAD
;; Wird beim Start von BricsCAD automatisch ausgefuehrt
;; ============================================================
(defun ssg-lib-startup ( / lisp-pfad menu-pfad)
;; Pfade aus Umgebungsvariablen lesen
(setq lisp-pfad (getenv "DXFM_LISP"))
(setq menu-pfad (getenv "DXFMAKRO"))
(if (null lisp-pfad)
(progn
(princ "\n[SSG_LIB] FEHLER: DXFM_LISP nicht gesetzt!")
(princ "\n[SSG_LIB] Bitte zuerst bin\\setenv.bat ausfuehren.")
)
(progn
(princ "\n[SSG_LIB] Lade SSG_LIB Umgebung...")
;; LISP-Pfad zum BricsCAD-Suchpfad hinzufuegen
(setq curr-srch (getvar "SRCHPATH"))
(if (not (vl-string-search lisp-pfad curr-srch))
(setvar "SRCHPATH" (strcat curr-srch ";" lisp-pfad))
)
;; Dummy-Befehle laden
(if (findfile (strcat lisp-pfad "/SSG_LIB_Commands.lsp"))
(progn
(load (strcat lisp-pfad "/SSG_LIB_Commands.lsp"))
(princ "\n[SSG_LIB] SSG_LIB_Commands.lsp geladen.")
)
(princ "\n[SSG_LIB] WARNUNG: SSG_LIB_Commands.lsp nicht gefunden!")
)
;; VarioFoerderer laden
(if (findfile (strcat lisp-pfad "/VarioFoerderer.lsp"))
(progn
(load (strcat lisp-pfad "/VarioFoerderer.lsp"))
(princ "\n[SSG_LIB] VarioFoerderer.lsp geladen.")
)
(princ "\n[SSG_LIB] WARNUNG: VarioFoerderer.lsp nicht gefunden!")
)
;; ILSModulInsert laden
(if (findfile (strcat lisp-pfad "/ILSModulInsert.lsp"))
(progn
(load (strcat lisp-pfad "/ILSModulInsert.lsp"))
(princ "\n[SSG_LIB] ILSModulInsert.lsp geladen.")
)
(princ "\n[SSG_LIB] WARNUNG: ILSModulInsert.lsp nicht gefunden!")
)
;; Menue laden
(if menu-pfad
(progn
(setq menu-datei (strcat menu-pfad "/menu/SSG_LIB.mnu"))
(if (findfile menu-datei)
(progn
(command "_.MENULOAD" menu-datei)
(princ "\n[SSG_LIB] Menue SSG_LIB.mnu geladen.")
)
(princ (strcat "\n[SSG_LIB] WARNUNG: " menu-datei " nicht gefunden!"))
)
)
)
(princ "\n[SSG_LIB] Startup abgeschlossen.")
)
)
(princ)
)
;; Startup ausfuehren
(ssg-lib-startup)
-3
View File
@@ -1,3 +0,0 @@
call "%~dp0setenv.bat"
echo DXFMAKRO=%DXFMAKRO%"
start "" %BRISCAD%
+3
View File
@@ -0,0 +1,3 @@
call "%~dp0setenv.bat"
echo DXFMAKRO=%DXFMAKRO%
start "" %BRISCAD% /s "%DXFM_BIN%\startup.scr"