[FEMAP API] How to halt VBA code until Nastran has finished calculating?
[FEMAP API] How to halt VBA code until Nastran has finished calculating?
(OP)
Hi,
I'm developing a macro in Excel which generates an analysis case, and then subsequently reads out certain areas of the f06 output file. In order to properly implement such a function I would need to be able to halt my code once it runs Nastran so that the proceeding steps are only executed after the output file has been successfully created.
I have been looking through the documentation on VBA and the FEMAP API help file, but so far I haven't really found anything that seemed like an appropriate way to implement this. While I'm continuing my search, I'm wondering, maybe somebody who frequents this forum has encountered a similar situation where they needed something similar?
Any help would be appreciated!
kind regards,
Z
I'm developing a macro in Excel which generates an analysis case, and then subsequently reads out certain areas of the f06 output file. In order to properly implement such a function I would need to be able to halt my code once it runs Nastran so that the proceeding steps are only executed after the output file has been successfully created.
I have been looking through the documentation on VBA and the FEMAP API help file, but so far I haven't really found anything that seemed like an appropriate way to implement this. While I'm continuing my search, I'm wondering, maybe somebody who frequents this forum has encountered a similar situation where they needed something similar?
Any help would be appreciated!
kind regards,
Z





RE: [FEMAP API] How to halt VBA code until Nastran has finished calculating?
Perhaps something similar to the following.
Call it from your routine by:
RunNastran("C:\mypath\myfile.bdf")
CODE --> VBA
Sub RunNastran(FilenameAndPath As String) ' Send a file with full path to this subroutine ' The command will be run in a shell window Dim WshShell As Object Dim ShellCmd As String Dim FilePath As String Dim FileName As String 'executable file name FileName = Dir(FilenameAndPath) 'Dir returns the name of the file FilePath = Left(FilenameAndPath, Len(FilenameAndPath) - Len(FileName) - 1) Set WshShell = CreateObject("WScript.Shell") ' Setting the window directory to the incoming file location WshShell.CurrentDirectory = FilePath ' chr(34) is a double quote (used if spaces in the path) ' add additional arguments to the end of the ShellCmd variable as needed. ShellCmd = chr(34) & "C:\MSC.Software\MD_Nastran\20101\bin\mdnastran.exe" & chr(34) _ & " " _ & chr(34) & FileName & chr(34) ' Run options: See http://ss64.com/vb/run.html for more options. ' 1 displays the shell window ' True waits for the command to complete WshShell.Run ShellCmd, 1, True Set WshShell = Nothing End SubDanny