diff --git a/CAD/Code/bin/create_assemblies.bat b/CAD/Code/bin/create_assemblies.bat index cea6dad..af81c5e 100644 --- a/CAD/Code/bin/create_assemblies.bat +++ b/CAD/Code/bin/create_assemblies.bat @@ -1,10 +1,18 @@ @echo off -REM ~dp0 steht für das Verzeichnis, in der diese Datei liegt +setlocal +SET "MANAGE=%~dp0manage_interpreter.bat" -call setenv.bat +CALL "%MANAGE%" activate +if errorlevel 1 ( + echo ERROR: Failed to activate Python environment + exit /b 1 +) -REM Beispielaufruf mit Parametern: -REM --in: Ordner mit .par-Dateien (optional. Standard: Input) -REM --out: Zielverzeichnis (optional. Standard: Work) +pushd "%PROJECT%" -python %PROJECT_LIB%\create_assemblies.py %* \ No newline at end of file +"%VIRTUAL_ENV%\Scripts\python.exe" -m lib.create_assemblies %* +set PYTHON_EXIT=%ERRORLEVEL% + +popd +CALL "%MANAGE%" deactivate +exit /b %PYTHON_EXIT% diff --git a/CAD/Code/bin/diff_dimensions.bat b/CAD/Code/bin/diff_dimensions.bat index adecbf9..06b28d8 100644 --- a/CAD/Code/bin/diff_dimensions.bat +++ b/CAD/Code/bin/diff_dimensions.bat @@ -1,6 +1,18 @@ @echo off -REM ~dp0 steht für das Verzeichnis, in der diese Datei liegt +setlocal +SET "MANAGE=%~dp0manage_interpreter.bat" -call setenv.bat +CALL "%MANAGE%" activate +if errorlevel 1 ( + echo ERROR: Failed to activate Python environment + exit /b 1 +) -python "%PROJECT_LIB%\diff_dimensions.py" %* \ No newline at end of file +pushd "%PROJECT%" + +"%VIRTUAL_ENV%\Scripts\python.exe" -m lib.diff_dimensions %* +set PYTHON_EXIT=%ERRORLEVEL% + +popd +CALL "%MANAGE%" deactivate +exit /b %PYTHON_EXIT% diff --git a/CAD/Code/bin/get_all_differences.bat b/CAD/Code/bin/get_all_differences.bat index 615ad2f..71d6b40 100644 --- a/CAD/Code/bin/get_all_differences.bat +++ b/CAD/Code/bin/get_all_differences.bat @@ -23,4 +23,4 @@ set /p TOLERANCE=Gib die Toleranz ein (Standard: %DEFAULT_TOLERANCE%): if "%TOLERANCE%"=="" set "TOLERANCE=%DEFAULT_TOLERANCE%" REM Aufruf des Skripts mit den eingegebenen oder Standardwerten -call diff_dimensions.bat --type %TYPE% --json_2d %JSON2D% --json_dimensions %JSONDIM% --tolerance %TOLERANCE% +call "%~dp0diff_dimensions.bat" --type %TYPE% --json_2d %JSON2D% --json_dimensions %JSONDIM% --tolerance %TOLERANCE% diff --git a/CAD/Code/bin/get_cmd.bat b/CAD/Code/bin/get_cmd.bat index 4dab2dd..27d2fbb 100644 --- a/CAD/Code/bin/get_cmd.bat +++ b/CAD/Code/bin/get_cmd.bat @@ -1,4 +1,4 @@ @echo off -call setenv.bat +call "%~dp0setenv.bat" start diff --git a/CAD/Code/bin/get_dimensions.bat b/CAD/Code/bin/get_dimensions.bat index e720092..0da1b92 100644 --- a/CAD/Code/bin/get_dimensions.bat +++ b/CAD/Code/bin/get_dimensions.bat @@ -1,10 +1,18 @@ @echo off -REM ~dp0 steht für das Verzeichnis, in der diese Datei liegt +setlocal +SET "MANAGE=%~dp0manage_interpreter.bat" -call setenv.bat +CALL "%MANAGE%" activate +if errorlevel 1 ( + echo ERROR: Failed to activate Python environment + exit /b 1 +) -REM Beispielaufruf mit Parametern: -REM --in: Ordner mit .asm-Dateien (optional. Standard: Work) -REM --out: Zielverzeichnis (optional. Standard: Work\stl_export) +pushd "%PROJECT%" -python %PROJECT_LIB%\read_variables.py %* \ No newline at end of file +"%VIRTUAL_ENV%\Scripts\python.exe" -m lib.read_variables %* +set PYTHON_EXIT=%ERRORLEVEL% + +popd +CALL "%MANAGE%" deactivate +exit /b %PYTHON_EXIT% diff --git a/CAD/Code/bin/manage_interpreter.bat b/CAD/Code/bin/manage_interpreter.bat new file mode 100644 index 0000000..0c4366a --- /dev/null +++ b/CAD/Code/bin/manage_interpreter.bat @@ -0,0 +1,35 @@ +@echo off +CALL "%~dp0setenv.bat" + +IF /I "%1"=="activate" GOTO activate +IF /I "%1"=="deactivate" GOTO deactivate +IF /I "%1"=="activate_interpreter" GOTO activate +IF /I "%1"=="deactivate_interpreter" GOTO deactivate +GOTO :eof + + +:activate +REM Interpreter wählen +IF DEFINED NETWORK_PYTHON ( + SET PYTHON_EXE=%NETWORK_PYTHON%\python.exe +) ELSE ( + SET PYTHON_EXE=python +) + +REM venv sicherstellen +IF NOT EXIST "%PROJECT%\.venv" ( + "%PYTHON_EXE%" -m venv "%PROJECT%\.venv" +) + +REM venv aktivieren +CALL "%PROJECT%\.venv\Scripts\activate.bat" + +REM Interpreter festnageln +SET VIRTUAL_ENV_PYTHON=%PYTHON_EXE% +GOTO :eof + + +:deactivate +CALL "%PROJECT%\.venv\Scripts\deactivate.bat" +SET VIRTUAL_ENV_PYTHON= +GOTO :eof diff --git a/CAD/Code/bin/save_stl.bat b/CAD/Code/bin/save_stl.bat index 5d7dd95..4dedf65 100644 --- a/CAD/Code/bin/save_stl.bat +++ b/CAD/Code/bin/save_stl.bat @@ -1,10 +1,18 @@ @echo off -REM ~dp0 steht für das Verzeichnis, in der diese Datei liegt +setlocal +SET "MANAGE=%~dp0manage_interpreter.bat" -call setenv.bat +CALL "%MANAGE%" activate +if errorlevel 1 ( + echo ERROR: Failed to activate Python environment + exit /b 1 +) -REM Beispielaufruf mit Parametern: -REM --in: Ordner mit .asm-Dateien (optional. Standard: Work) -REM --out: Zielverzeichnis (optional. Standard: Work\stl_export) +pushd "%PROJECT%" -python %PROJECT_LIB%\save_stl.py %* \ No newline at end of file +"%VIRTUAL_ENV%\Scripts\python.exe" -m lib.save_stl %* +set PYTHON_EXIT=%ERRORLEVEL% + +popd +CALL "%MANAGE%" deactivate +exit /b %PYTHON_EXIT% diff --git a/CAD/Code/bin/setenv.bat b/CAD/Code/bin/setenv.bat index 876b56d..477619f 100644 --- a/CAD/Code/bin/setenv.bat +++ b/CAD/Code/bin/setenv.bat @@ -1,17 +1,14 @@ @echo off -REM ~dp0 steht für das Verzeichnis, in der diese Datei liegt +REM ~dp0 steht für das Verzeichnis, in der diese Datei liegt pushd %~dp0\.. -REM for /f "delims=" %%i in ('git rev-parse --show-toplevel') do set SSG_RD_DIR=%%i +set PROJECT=%cd% - -set PROJECT_DIR=%cd% - -set PROJECT_BIN=%PROJECT_DIR%\bin -set PROJECT_LIB=%PROJECT_DIR%\lib -set PROJECT_WORK=%PROJECT_DIR%\work -set PROJECT_DATA=%PROJECT_DIR%\data -set PROJECT_INPUT=%PROJECT_DIR%\input +set PROJECT_BIN=%PROJECT%\bin +set PROJECT_LIB=%PROJECT%\lib +set PROJECT_WORK=%PROJECT%\work +set PROJECT_DATA=%PROJECT%\data +set PROJECT_INPUT=%PROJECT%\input set PROJECT_TEMPLATE=\\ssg.local\freigaben\RuleDesigner\Templates\CreateAssemblies if not exist %PROJECT_WORK% mkdir %PROJECT_WORK% @@ -23,4 +20,4 @@ set PROJECT_JSON_TEFBOGEN=%SSG_RD_DIR%\SVGs\Omniflo\python\TEFBogen\json set PROJECT_JSON_TEFWEICHE=%SSG_RD_DIR%\SVGs\Omniflo\python\TEFWeiche\json popd -goto :eof \ No newline at end of file +goto :eof diff --git a/CAD/Code/lib/__init__.py b/CAD/Code/lib/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/CAD/templates/ILS/BogenVario_auf_3.par b/CAD/templates/ILS/BogenVario_auf_3.par index b7b95cd..808de39 100644 Binary files a/CAD/templates/ILS/BogenVario_auf_3.par and b/CAD/templates/ILS/BogenVario_auf_3.par differ