×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

[FEMAP API] How to halt VBA code until Nastran has finished calculating?

[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

RE: [FEMAP API] How to halt VBA code until Nastran has finished calculating?

Z,

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 Sub 

Danny

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources