@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 CUSTOMIZE_SCRIPT=%SCRIPT_FOLDER%\apply_customize_setting.rb

rem ### STEP BOM/JT to NX ###
set PID=184141
if /i "%~x1" == ".stpx" (
  set PID=175141
)

rem ### elybatch
set ELYBATCH=%E3DS_COMPONENT%\tools\win\elybatch.exe
rem ### files
set CONFIG_FILE=%~dp0config.cfg
set SCENARIOFILE=%~dp0scenario.xml
set PARAMETER_FILE=%~dp0sf_to_nx.prm

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
