Lisp Routine erstellt, die jedem Element beim Export eine Id gibt. Menüs dynamisch gemacht, d.h. die Lisp Routinen werden erst geladen, wenn sie vom Nutzer per MEnü aufgerufen wurden
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
;; ============================================================
|
||||
;; SSG_LIB.mnl - Automatisch geladen beim MENULOAD von SSG_LIB.mnu
|
||||
;;
|
||||
;; Definiert den Lazy-Loader (ssg-ensure) und laedt die
|
||||
;; Kern-Module (ssg_core, ssg_dbg, ssg_dialog, ssg_layer).
|
||||
;; Feature-Module werden erst bei Menueklick nachgeladen.
|
||||
;; ============================================================
|
||||
|
||||
;; Globale Variable: Pfad zu den LISP-Dateien (aus Umgebungsvariable)
|
||||
(setq *ssg-lisp-pfad* (getenv "DXFM_LISP"))
|
||||
(if *ssg-lisp-pfad*
|
||||
(setq *ssg-lisp-pfad* (vl-string-translate "\\" "/" *ssg-lisp-pfad*))
|
||||
)
|
||||
|
||||
;; ------------------------------------------------------------
|
||||
;; ssg-ensure - Lazy-Loader fuer SSG_LIB Module
|
||||
;;
|
||||
;; Prueft ob ein Modul bereits geladen ist (via *ssg-<modul>-loaded*).
|
||||
;; Wenn nicht, laedt es aus DXFM_LISP.
|
||||
;; Laedt automatisch Kern-Abhaengigkeiten (core, dbg, dialog, layer)
|
||||
;; falls diese noch nicht geladen sind.
|
||||
;; ------------------------------------------------------------
|
||||
(defun ssg-ensure (modul / flag-sym datei)
|
||||
;; Flag-Symbol: *ssg-ssg_core-loaded* etc.
|
||||
(setq flag-sym (read (strcat "*ssg-" modul "-loaded*")))
|
||||
|
||||
(if (not (eval flag-sym))
|
||||
(progn
|
||||
;; Pfad pruefen
|
||||
(if (null *ssg-lisp-pfad*)
|
||||
(progn
|
||||
(setq *ssg-lisp-pfad* (getenv "DXFM_LISP"))
|
||||
(if *ssg-lisp-pfad*
|
||||
(setq *ssg-lisp-pfad* (vl-string-translate "\\" "/" *ssg-lisp-pfad*))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(if (null *ssg-lisp-pfad*)
|
||||
(progn
|
||||
(alert "SSG_LIB: DXFM_LISP nicht gesetzt!\nBitte zuerst setenv.bat ausfuehren.")
|
||||
(princ "\n[SSG_LIB] FEHLER: DXFM_LISP nicht gesetzt!")
|
||||
)
|
||||
(progn
|
||||
;; Kern-Module als Abhaengigkeit laden (falls noch nicht geschehen)
|
||||
(if (not *ssg-core-loaded*)
|
||||
(progn
|
||||
(ssg-ensure-load "ssg_core")
|
||||
(set '*ssg-core-loaded* t)
|
||||
(ssg-load-config)
|
||||
)
|
||||
)
|
||||
(if (not *ssg-dbg-loaded*)
|
||||
(progn
|
||||
(ssg-ensure-load "ssg_dbg")
|
||||
(set '*ssg-dbg-loaded* t)
|
||||
;; Debug-Log oeffnen
|
||||
(if (and (atoms-family 1 '("DBGOPEN")) (getenv "DXFM_LOG"))
|
||||
(dbgopen "debugfile.dbg" "DXFM_LOG")
|
||||
)
|
||||
)
|
||||
)
|
||||
(if (not *ssg-dialog-loaded*)
|
||||
(progn
|
||||
(ssg-ensure-load "ssg_dialog")
|
||||
(set '*ssg-dialog-loaded* t)
|
||||
)
|
||||
)
|
||||
(if (not *ssg-layer-loaded*)
|
||||
(progn
|
||||
(ssg-ensure-load "ssg_layer")
|
||||
(set '*ssg-layer-loaded* t)
|
||||
)
|
||||
)
|
||||
|
||||
;; Jetzt das angeforderte Modul laden (falls nicht schon ein Kern-Modul)
|
||||
(if (not (eval flag-sym))
|
||||
(progn
|
||||
(ssg-ensure-load modul)
|
||||
(set flag-sym t)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(princ)
|
||||
)
|
||||
|
||||
;; Hilfsfunktion: Datei laden mit Fehlerbehandlung
|
||||
(defun ssg-ensure-load (modul / datei result)
|
||||
(setq datei (strcat *ssg-lisp-pfad* "/" modul ".lsp"))
|
||||
(if (findfile datei)
|
||||
(progn
|
||||
(setq result (vl-catch-all-apply 'load (list datei)))
|
||||
(if (vl-catch-all-error-p result)
|
||||
(princ (strcat "\n[SSG_LIB] FEHLER beim Laden von " modul ": "
|
||||
(vl-catch-all-error-message result)))
|
||||
(princ (strcat "\n[SSG_LIB] Geladen: " modul ".lsp"))
|
||||
)
|
||||
)
|
||||
(princ (strcat "\n[SSG_LIB] WARNUNG: " datei " nicht gefunden!"))
|
||||
)
|
||||
)
|
||||
|
||||
;; ------------------------------------------------------------
|
||||
;; Beim MNL-Laden: Alle Module laden + Menue einhaengen
|
||||
;; ------------------------------------------------------------
|
||||
(if *ssg-lisp-pfad*
|
||||
(progn
|
||||
;; Alle Module in der richtigen Reihenfolge laden
|
||||
(ssg-ensure "ssg_core")
|
||||
(ssg-ensure "ssg_dbg")
|
||||
(ssg-ensure "ssg_dialog")
|
||||
(ssg-ensure "ssg_layer")
|
||||
(ssg-ensure "ssg_id")
|
||||
(ssg-ensure "KreiselInsert")
|
||||
(ssg-ensure "VarioFoerderer")
|
||||
(ssg-ensure "Gefaellestrecke")
|
||||
(ssg-ensure "export")
|
||||
(ssg-ensure "tests")
|
||||
(ssg-ensure "OmniModulInsert")
|
||||
(ssg-ensure "SSG_LIB_Commands")
|
||||
|
||||
;; Pulldown-Menue in die Menueleiste einhaengen
|
||||
(menucmd "P13=+SSG_LIB.POP1")
|
||||
(setvar "DBLCLKEDIT" 0)
|
||||
(princ "\n[SSG_LIB] Alle Module geladen. Menue aktiv.")
|
||||
)
|
||||
(princ "\n[SSG_LIB] WARNUNG: DXFM_LISP nicht gesetzt - Befehle nicht verfuegbar.")
|
||||
)
|
||||
(princ)
|
||||
Reference in New Issue
Block a user