Clearing the database with script

Hello,

I am currently running a large number of simulations in SOFiSTiK with a Teddy script. For each simulation, I have to change a single number in my script, run the script and then wait a few minutes to start over. At the end of each simulation, the script writes the results into some files which contain that number in their names.

It would be helpful if I’d be able to code this as a loop where the number in question updates automatically, and the whole simulation is repeated (or less elegantly even to just copy paste the entire script a few times, one copy after the other, and simply change the number in each copy). That way, I’d only have to run the script once, let it run for about an hour or so, and in the end I’d have all of the output files of all simulations.

In order to do that, I should be able to clear everything stored in the database at the end of each simulation, so that it starts from a blank page at the beginning of each simulation (just as is the case now, when I run the script manually for each simulation). Otherwise, the script would try to re-create some elements or nodes in the 3D model which already exist, or some elements of the previous simulations would still be there when they aren’t supposed to be there.

So I’m wondering if there’s a possibility to clear everything in the database with a record or command in the script. I’ve been looking in the manual, but haven’t found anything unfortunately.

Thank you for reading.

Hello,

For deleting the cdb with the same name as the teddy file use:
+Sys Del $(name).cdb
For deleting all cdbs in the folder use:
+Sys Del *.cdb

Since you want to run several jobs after each other you could do the following:

  • Write the entire calculation script in one teddy file.
    Call it “main.dat”
  • For each version of the calculation create a teddy script with a number
    E.g.: calc1.dat, calc2.dat, calc3.dat, …
  • Each calcX.dat consists only of the line:
    #Include main.dat
  • Write a bat script that calls each file after each other containing:
    “C:/Program Files/…/Sofistik 2020/sps.exe” -b calc1.dat
    “C:/Program Files/…/Sofistik 2020/sps.exe” -b calc2.dat
    “C:/Program Files/…/Sofistik 2020/sps.exe” -b calc3.dat
    Or (little more elegant):
    Set my_exe=“C:/Program Files/…/Sofistik 2020/sps.exe” -b
    For %%G In (calc*.dat) Do %my_exe% %%G

If you use the bat-script option, you do not have to delete the cdb, since each calulation will have cdbs and plbs named calcX.*

1 Like

Thank you once again, sfr. I tried the first solution so far which already works perfectly. I might try the bat-script solution as well later on.