diff --git a/bin/on_start.lsp b/bin/on_start.lsp index 32dc255..405a354 100644 --- a/bin/on_start.lsp +++ b/bin/on_start.lsp @@ -106,59 +106,78 @@ ;; DBLCLKEDIT deaktivieren (Block-Editor nicht bei Doppelklick oeffnen) (setvar "DBLCLKEDIT" 0) - ;; PyRx BRX-Plugin laden (benoetigt fuer PYLOAD-Befehl) + ;; PyRx BRX-Plugin: wird via BricsCAD Startup-Suite geladen (nicht via arxload). + ;; Grund: PyRxV25.0.brx muss vor dem LISP-Startup aktiv sein. + ;; Einmalige Einrichtung: APPLOAD -> PyRxV25.0.brx -> "Startup Suite" hinzufuegen. + ;; + ;; Pyrx-Pfad: aus PYTHONHOME (system Python), nicht aus .venv (if menu-pfad (progn - (setq pyrx-pfad (strcat menu-pfad "/.venv/Lib/site-packages/pyrx")) - ;; BricsCAD-Version aus ACADVER ermitteln (z.B. "25.0.0.0" -> "25") (setq acadver-str (getvar "ACADVER")) (setq ver-punkt (vl-string-search "." acadver-str)) - (setq ver-major (if ver-punkt - (substr acadver-str 1 ver-punkt) - "25" - )) - (setq brx-datei (strcat pyrx-pfad "/RxLoaderV" ver-major ".0.brx")) - (if (findfile brx-datei) - (progn - (setq brx-result (vl-catch-all-apply 'arxload (list brx-datei))) - (ssg-dbg-pyrx pyrx-pfad ver-major brx-datei brx-result) - (princ (strcat "\n[SSG_LIB] PyRx BRX geladen (V" ver-major "): " brx-datei)) + (setq ver-major (if ver-punkt (substr acadver-str 1 ver-punkt) "25")) + ;; Pyrx-Pfad: .venv (primaer, dort installiert), dann System/User Python + (setq pyrx-pfad + (cond + ((findfile (strcat menu-pfad "/.venv/Lib/site-packages/pyrx/RxLoaderV" ver-major ".0.brx")) + (strcat menu-pfad "/.venv/Lib/site-packages/pyrx")) + ((and (getenv "PYTHONHOME") + (findfile (strcat (getenv "PYTHONHOME") "/Lib/site-packages/pyrx/RxLoaderV" ver-major ".0.brx"))) + (strcat (getenv "PYTHONHOME") "/Lib/site-packages/pyrx")) + ((and (getenv "APPDATA") + (findfile (strcat (getenv "APPDATA") "/Python/Python312/site-packages/pyrx/RxLoaderV" ver-major ".0.brx"))) + (strcat (getenv "APPDATA") "/Python/Python312/site-packages/pyrx")) + (t nil) ) - (progn - (princ (strcat "\n[SSG_LIB] FEHLER: PyRx BRX nicht gefunden: " brx-datei)) - (princ "\n[SSG_LIB] Versuche Fallback-Versionen...") - (foreach ver '("26" "25" "24") - (if (not (= ver ver-major)) + ) + ;; Wenn PyRx noch nicht aktiv (nicht via Startup Suite geladen): arxload versuchen + (if (not (member (strcat "rxloaderv" ver-major ".0.brx") (arx))) + (if pyrx-pfad + (progn + (setq brx-datei (strcat pyrx-pfad "/RxLoaderV" ver-major ".0.brx")) + (setq brx-result (vl-catch-all-apply 'arxload (list brx-datei))) + (ssg-dbg-pyrx pyrx-pfad ver-major brx-datei brx-result) + (if (vl-catch-all-error-p brx-result) (progn - (setq brx-fallback (strcat pyrx-pfad "/RxLoaderV" ver ".0.brx")) - (if (findfile brx-fallback) - (progn - (arxload brx-fallback) - (princ (strcat "\n[SSG_LIB] PyRx BRX Fallback geladen (V" ver "): " brx-fallback)) - ) - ) + (princ (strcat "\n[SSG_LIB] FEHLER: RxLoaderV" ver-major ".0.brx nicht geladen: " + (vl-catch-all-error-message brx-result))) + (princ "\n[SSG_LIB] HINWEIS: PyRx einmalig via APPLOAD -> Startup Suite einrichten.") ) + (princ (strcat "\n[SSG_LIB] PyRx RxLoader geladen (V" ver-major "): " brx-datei)) ) ) + (princ (strcat "\n[SSG_LIB] WARNUNG: PyRxV" ver-major ".0.brx nicht gefunden." + "\n PYTHONHOME=" (if (getenv "PYTHONHOME") (getenv "PYTHONHOME") "nicht gesetzt"))) + ) + (progn + (dbgmsg "[PyRx] PyRx bereits via Startup-Suite aktiv") + (princ (strcat "\n[SSG_LIB] PyRx (V" ver-major ") via Startup-Suite aktiv.")) ) ) ) ) - ;; Python-Module laden (PyRx) + ;; Python-Module laden (PyRx) - nur wenn PYLOAD verfuegbar (dbgmsg "[PYLOAD] --- Python-Module ---") - (if menu-pfad - (foreach pymod '("eckrad" "kreisel" "dblclick" "omniflo" "omniflo_boegen" "omniflo_weichen") - (if (findfile (strcat menu-pfad "/lib/elemente/" pymod ".py")) - (progn - (dbgmsg (strcat "PYLOAD start: " pymod ".py")) - (command "PYLOAD" (strcat menu-pfad "/lib/elemente/" pymod ".py")) - (dbgmsg (strcat "PYLOAD done: " pymod ".py")) - (princ (strcat "\n[SSG_LIB] Python-Modul " pymod ".py geladen.")) - ) - (progn - (dbgmsg (strcat "PYLOAD skip: " pymod ".py -- nicht gefunden")) - (princ (strcat "\n[SSG_LIB] HINWEIS: " pymod ".py nicht gefunden.")) + (if (not (member "PYLOAD" (atoms-family 0))) + (progn + (dbgmsg "[PYLOAD] PYLOAD nicht verfuegbar - ueberspringe alle Module") + (princ "\n[SSG_LIB] WARNUNG: PYLOAD nicht verfuegbar (PyRx nicht geladen).") + (princ "\n[SSG_LIB] Python-Befehle (KreiselInsert etc.) nicht aktiv.") + ) + (if menu-pfad + (foreach pymod '("eckrad" "kreisel" "dblclick" "omniflo" "omniflo_boegen" "omniflo_weichen") + (if (findfile (strcat menu-pfad "/lib/elemente/" pymod ".py")) + (progn + (dbgmsg (strcat "PYLOAD start: " pymod ".py")) + (command "PYLOAD" (strcat menu-pfad "/lib/elemente/" pymod ".py")) + (dbgmsg (strcat "PYLOAD done: " pymod ".py")) + (princ (strcat "\n[SSG_LIB] Python-Modul " pymod ".py geladen.")) + ) + (progn + (dbgmsg (strcat "PYLOAD skip: " pymod ".py -- nicht gefunden")) + (princ (strcat "\n[SSG_LIB] HINWEIS: " pymod ".py nicht gefunden.")) + ) ) ) ) diff --git a/bin/setenv.bat b/bin/setenv.bat index 13ab96c..215c744 100644 --- a/bin/setenv.bat +++ b/bin/setenv.bat @@ -30,10 +30,14 @@ set BRISCAD="C:\Program Files\Bricsys\BricsCAD V25 de_DE\bricscad.exe" +REM Python-Umgebung fuer PyRx (BricsCAD benoetigt PYTHONHOME + python312.dll im PATH) +set "PYTHONHOME=C:\Python312" +set "PATH=C:\Python312;%PATH%" + REM Python-Pfad erweitern (nur wenn noch nicht vorhanden) echo %PYTHONPATH% | find /i "%DXFM_LIB%" >nul if errorlevel 1 ( - set "PYTHONPATH=%DXFM_LIB%;%PYTHONPATH%" + set "PYTHONPATH=%DXFM_LIB%;%DXFMAKRO%\.venv\Lib\site-packages;%PYTHONPATH%" ) REM Ordner erstellen falls sie nicht existieren @@ -53,6 +57,7 @@ REM Umgebungsvariablen anzeigen echo. echo ================================================================ echo DXFMAKRO = %DXFMAKRO% +echo PYTHONHOME = %PYTHONHOME% echo PYTHONPATH = %PYTHONPATH% echo ================================================================ echo. diff --git a/lib/elemente/omniflo.py b/lib/elemente/omniflo.py index ddb0cee..95be3c0 100644 --- a/lib/elemente/omniflo.py +++ b/lib/elemente/omniflo.py @@ -16,7 +16,6 @@ from elemente.utils import ( get_data_path, load_json_data, get_block_path, - read_block_attribs, ensure_block_from_dxf, ) diff --git a/lib/elemente/omniflo_weichen.py b/lib/elemente/omniflo_weichen.py index 848eab8..59ff1f6 100644 --- a/lib/elemente/omniflo_weichen.py +++ b/lib/elemente/omniflo_weichen.py @@ -6,8 +6,6 @@ import wx import PyRx as Rx -import PyDb as Db -import PyEd as Ed from elemente.omniflo import ( load_weichen, diff --git a/requirements.txt b/requirements.txt index 9409f5a..59150b5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,3 @@ ezdxf==1.4.1 pytest==9.0.2 -# PyRx - BricsCAD Python API (liefert .brx Plugin-Dateien und Python-Wrapper) -# WICHTIG: Benoetigt Python 3.12 (py -3.12 -m venv) -cad-pyrx >= 2.0.0 -wxpython >= 4.2.0