×
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

API Events handling

API Events handling

API Events handling

(OP)
Hey there guys!

I'm using Visual Basic code within the Visual Studio IDE to automate an analysis within Femap. Up until now, I've just told VS to wait for a time duration I specify while Femap is running an analysis, s.t. Femap has time to generate the data that VS will Get and then write it into an excel file for me.

I want to transition to using Femap Events. These allow us to generate and send messages that go into a message queue that can be accessed by other programs. The section there in the API reference gives sample code, though it isn't VB. I haven't been able to correctly modify it to run in VS, and so I've been researching message queues in VS (MSMQ) but it's byzantine and complicated and I haven't had any joy yet.

I was wondering if anyone had a similar experience, or perhaps even had some sample code out there that shows how to tell VS to listen for messages, tells Femap to generate them, and tells VS to act upon getting the message.

Thanks in advance for the help!
Marce

RE: API Events handling

(OP)
Hey you guys! I've managed to get a solution to this problem, and I wanted to share!

I spoke with Siemens' tech support, and they gave me the following, comments mine.

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim fam As femap.AnalysisMgr
fam = app.feAnalysisMgr
fam.Analyze(1)
CheckAnalysisState(app.Info_Count(femap.zDataType.FT_OUT_CASE))
'this line calls the private sub below. Place it immediately beneath the analyze command
End Sub

Private Sub CheckAnalysisState(OutputCount As Long)
Do While app.Info_Count(femap.zDataType.FT_OUT_CASE) = OutputCount
Threading.Thread.Sleep(100)
'the number here is time in milliseconds. Set it higher than 100, maybe 2000 or so
app.feAppMessage(femap.zMessageColor.FCM_COMMAND, "Waiting for analysis...")
'this line writes to the message box inside femap
Loop
MsgBox("Analysis imported... do something")
End Sub

This code watches the output count within femap and puts the thread to sleep until the output count has changed, which happens after automatic loading of results has been completed.

In order to use it, you must include a reference to the femap type library in your development environment. In Visual Studio, go to the Project menu, then hit add reference, then find femap.tlb in the femap directory.

Essentially, I stuck the private sub CheckAnalysisState at the top of my code, then called it (with CheckAnalysisState(app.info ... FT_Out_Case) right after the I issued the analysis command. Works like a charm!

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