@echo off

REM ================================================================
REM TEST - Umgebungsvariablen Setup
REM ================================================================

echo Setting up environment variables for DXFMAKROS ...

REM Basis-Projektpfad (aktueller Ordner)
set "DXFMAKRO=%~dp0.."
if "%DXFMAKRO:~-6%"=="bin\.." set "DXFMAKRO=%DXFMAKRO:~0,-6%"
if "%DXFMAKRO:~-1%"=="\" set "DXFMAKRO=%DXFMAKRO:~0,-1%"

REM Pfade fuer verschiedene Komponenten
set "DXFM_BIN=%DXFMAKRO%\bin"
set "DXFM_LIB=%DXFMAKRO%\lib"
set "DXFM_DATA=%DXFMAKRO%\data"
set "DXFM_CFG=%DXFMAKRO%\cfg"
set "DXFM_LOG=%DXFMAKRO%\log"
set "DXFM_BLOCKS=%DXFMAKRO%\Blocks"
set "DXFM_LISP=%DXFMAKRO%\Lisp"
set "DXFM_DCL=%DXFMAKRO%\dcl"
set "DXFM_RESULTS=%DXFMAKRO%\results"

set BRISCAD="C:\Program Files\Bricsys\BricsCAD V25 de_DE\bricscad.exe"



REM Python-Pfad erweitern (nur wenn noch nicht vorhanden)
echo %PYTHONPATH% | find /i "%DXFM_LIB%" >nul
if errorlevel 1 (
    set "PYTHONPATH=%DXFM_LIB%;%PYTHONPATH%"
)

REM Ordner erstellen falls sie nicht existieren
if not exist "%DXFM_BIN%" mkdir "%DXFM_BIN%"
if not exist "%DXFM_CFG%" mkdir "%DXFM_CFG%"
if not exist "%DXFM_LIB%" mkdir "%DXFM_LIB%"
if not exist "%DXFM_DATA%" mkdir "%DXFM_DATA%"
if not exist "%DXFM_BLOCKS%" mkdir "%DXFM_BLOCKS%"
if not exist "%DXFM_LISP%" mkdir "%DXFM_LISP%"
if not exist "%DXFM_RESULTS%" mkdir "%DXFM_RESULTS%"

REM Umgebungsvariablen anzeigen
echo.
echo ================================================================
echo DXFMAKRO         = %DXFMAKRO%
echo PYTHONPATH      = %PYTHONPATH%
echo ================================================================
echo.

REM Optionally keep window open
if "%1"=="--keep-open" pause
