Run solutions using a BAT file

Depending on the command switch you use, you can launch batch runs using the Windows cmd command. The following page presents sample code examples and explanations.

Copy the code from these examples to add them to a BAT file. To run, just double-click your BAT file from the Windows file explorer. Alternatively, you can use the following examples directly in a Windows command prompt.

Example 1: run analysis from XML, in solution’s run directory

set UGII_TMG_DIR=[Simcenter 3D installation]\NXCAE_EXTRAS\tmg

%UGII_TMG_DIR%\\com
tmgnx.cmd NX

Specify the correct absolute path to the Simcenter 3D installation when setting the UGII_TMG_DIR environment variable.

Note:
You can omit this first line if the UGII_TMG_DIR environment variable is globally set on your computer.

Example 2: run analysis from XML, in file directory

In this example, it is assumed that the UGII_TMG_DIR environment variable is already set.

%UGII_TMG_DIR%\\com
tmgnx.cmd NF

You can use this command in a Python code as follows:

os.chdir(directory) # Change directory to current xml location
    subprocess_cmd('set UGII_TMG_DIR='UGII_TMG_DIR'&%UGII_TMG_DIR%\\com
tmgnx.cmd NF -inPath '+ Runs[num2] +'_mod.xml')

In this code snippet, the subprocess_cmd function, which starts a shell command, and the values of the directory, UGII_TMG_DIR, and Runs[num2] variables must first be provided. '+ Runs[num2] +'_mod.xml indicates the path to the XML file.

Example 3: run thermal analyses in specified directories

In this example, you run simultaneously three thermal analyses from INPF, which are stored in the Run1, Run2, and Run3 folders. The commands must be run from the folder containing the Run1, Run2, and Run3 folders.

set UGII_TMG_DIR=[Simcenter 3D installation]\NXCAE_EXTRAS\tmg
FOR /L %%G IN (1,1,3) DO START /D .\Run%%G %UGII_TMG_DIR%\\com
tmgnx.cmd TA

These commands set the UGII_TMG_DIR environment variable, loops through the range 1 to 3, and starts TMG Executive Menu in Run1, Run2, and Run3 folders, respectively.