@echo off
setlocal


rem ### Edit ###
set OUTPUT_FOLDER=%~dp0

set E3DS_COMPONENT=XXX
set TIMEOUT=360


rem ### Do Not Edit ###
set INPUT_FILE_NAME=%1
set SCRIPT_FOLDER=%~dp0..\COMMON

set WORK_DIR=%OUTPUT_FOLDER%\work\%~n1
set RESULTS_DIR=%OUTPUT_FOLDER%\result\%~n1
set DAIMLER_SUPPLIER_SCRIPT=%SCRIPT_FOLDER%\interpret_daimler_setting.rb


rem ### PLMXML/JT to CATIA V5 ###
set PID=184171
if /i "%~x1" == ".plmxml" (
  set PID=194171
)

rem ### elybatch
set ELYBATCH=%E3DS_COMPONENT%\tools\win\elybatch.exe
rem ### files
set CONFIG_FILE=%~dp0daimler_config.cfg
set SCENARIOFILE=%~dp0daimler_scenario.xml
set PARAMETER_FILE=%~dp0daimler_plmxml_jt_to_v5.prm

rem ### environment variables
set ELY_PXFBT_CONVERT_EXTERNAL_FILENAME=1

rem ### mkdir
mkdir %WORK_DIR%
mkdir %RESULTS_DIR%

call :TRANSLATE %INPUT_FILE_NAME%

GOTO :END


rem *******************************************************
:TRANSLATE

set OUTPUT_FILE_NAME=%RESULTS_DIR%\%~n1
set LOG_NAME=%WORK_DIR%\%~n1.log
set XML_LOG_NAME=%~n1.xml
set SCENARIOLOG=%~n1_scenario_log.xml

"%ELYBATCH%" -f"%CONFIG_FILE%" -p%PID% -w"%WORK_DIR%" -i%INPUT_FILE_NAME% -o"%OUTPUT_FILE_NAME%" -u"%LOG_NAME%" -X"%XML_LOG_NAME%" -c"%PARAMETER_FILE%" -t%TIMEOUT% -S"%SCENARIOFILE%" -U"%SCENARIOLOG%"

goto :EOF
rem *******************************************************


:END
endlocal
