cancel
Showing results for 
Search instead for 
Did you mean: 

Femap API for Nastran batch runs

Experimenter
Experimenter

I have written a short Femap API to launch Nastran, bypassing the standard Femap Analysis window.

Simply it calls up a window to browse for the BDF file and run the Nastran executable:

 

NastranFilePath=GetFilePath(,"dat",,"Specify dat file",0)

NastranDeck =Mid(NastranFilePath,InStrRev(NastranFilePath,"\")+1,)

NastranCommand = NastranExecutable + " " + NastranDeck

rc = App.feFileExecute ( NastranCommand, False )

 

 

Now I would like to extend this script to run multiple BDF files in batch mode, one at a time since I have only one license available.

 

Anyone could help me on this?

 

Thanks.

1 REPLY

Re: Femap API for Nastran batch runs

Creator
Creator

Hi,

 

Are all the bdf files (or dat files as you specify in the GetFilePath command) you want to run in one directory? If so you can loop over all of them using the Dir function. The Dir function has no ability to traverse a tree recursively.

 

Do not forget you do need to wait for completion of the NASTRAN process or all runs will be started almost simultaneously, as the loop function is very fast. So use:

 

rc = App.feFileExecute ( NastranCommand, True)

 

The complete code would be something like:

    NastranFilePath=GetFilePath(,"dat",,"Specify dat file",0)
    NastranDeck = Mid(NastranFilePath,InStrRev(NastranFilePath,"\")+1,)
    Directory = Left(NastranFilePath, Len(NastranFilePath)-Len(NastranDeck))
    NastranFile = Dir(Directory & "*.dat")
    While (NastranFile <> "")
         NastranCommand = NastranExecutable + " " + NastranFile
         rc = App.feFileExecute ( NastranCommand, True)
         NastranFile = Dir
    Wend

 

Please note that there is no error handling in there that catches pressing cancel or any other errors that might occur.

 

I hope this helps.

 

Regards,

Gertjan