Looping to Automize Process in Sim Software

November 21, 2010 at 16:39:41
Specs: Windows XP
I am using a fire dynamics visualization software called Smokeview and I am trying to create a batch file that will allow me to render a series of images automatically. I am currently able to render one image at a specific time in the simulation, but I would like to render images from a start time to an end time with a given time step. Here is how one image is rendered. // is used for comments:

Command:
smokeview -runscript filename

Script File Saved in Simulation Directory:
RENDERDIR
. //render directory is the same as the simulation directory
LOADFILE
clark_1_0001_01.sf //name of simulation file
SETTIMEVAL=10 //time that the image is rendered in the simulation
RENDERONCE
clark_1_image1 //name of png file

Here was my attempt to automize the process of creating multiple images:

Batch File:
SET /P /A starttime=Enter start time here:
SET /P /A stepsize=Enter step size here:
SET /P /A endtime=Enter end time here:
SET /A ref=0 //variable is used to name image files
FOR /L %%i IN (%starttime%,%stepsize%,%endtime%) DO (
SET /A time=%%i //render an image at this time
SET /A ref=%ref%+1 //name the image using this variable
smokeview -runscript clark_1
)

clark_1 Script File:
RENDERDIR
.
LOADFILE
clark_1_0001_01.sf
SETTIMEVAL=%time% (%time% is not recognized)
RENDERONCE
clark_1_image%ref% (%ref% is not recognized)

Does anyone have any suggestions on how this can be done? Thanks for the help.

-Clark


See More: Looping to Automize Process in Sim Software

Report •

#1
November 22, 2010 at 04:24:27
This may take a bit of work. But a couple things to start.

[1] Avoid using an already defined var name, like TIME.

[2] Use local vars by starting with:

@echo off & setLocal EnableDELAYedeXpansion


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
November 23, 2010 at 23:43:00
Unfortunately, I am still having problems. To test sending variables from one batch to file to another I created the following two test files:

test1.bat:
@ECHO OFF
setlocal EnableDelayedExpansion
SET /P num=type a number here:
SET /P end=type last number here:
SET /P step=type step size here:
SET ref=0
FOR /l %%i IN (%num%, %step%, %end%) DO (
SET /A ref=ref+1
SET t=%%i
test2
)

test2.bat
@ECHO OFF
setlocal EnableDelayedExpansion
ECHO clark_!ref!
ECHO number !t!

The error that I am getting with this code is with the ECHO clark_!ref!. The first iteration it is executing correctly but then the number of r increases beyond the step size of 1 defined in test1.bat.
Also, it seems that the step size of FOR loops must be an integer. When I try using a a fraction or decimal the iterator value does not change.

Using the same t and ref variables from this test should be enough to render images from the simulation at integer time steps with irregular namings for the png files. However, this is not the case. The script file which is read by smoke view is the following, where t is time set in the batch file and ref increases by one each iteration in the for loop. Unfortunately, neither of these variables are recognized in the script file.
RENDERDIR
.
SETTIMEVAL=!t! (t is not recognized as a defined variable)
LOADFILE
clark_1_0001_01.sf
RENDERONCE
clark_1_!ref! (ref is not recognized as a defined variable)

The output in the command prompt from smoke view says:
Script: loading file clark...
file clark... was not loaded
Rendering to: clark_1_!ref!.png . Completed.

An image of the simulation at time zero named clark_1_!ref! is then saved in the directory.

Any other suggestions?

Thanks for your help.

-Clark


Report •

#3
November 24, 2010 at 17:30:30
:: PASSTEST.BAT
@echo off & setLocal EnableDELAYedeXpansion
for /f "tokens=* delims= " %%a in ('dir/b *.') do (
set V=%%a
call echotest.bat
)

=============================================
:: ECHOTEST.BAT
@echo off & setLocal EnableDELAYedeXpansion
echo.this is %0
echo.!V!

============== output ======================
this is echotest.bat
EXTRACT
this is echotest.bat
MYFILE
this is echotest.bat
PUTFILE
this is echotest.bat
MESS


=====================================
Life is too important to be taken seriously.

M2


Report •
Related Solutions


Ask Question