Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

FEMAP API Using feOutputCalculate

Status
Not open for further replies.

zanestoy

Structural
Apr 25, 2012
10
I am new to working with the FEMAP API and am trying to calculate some vectors using the API. I have used the Model->Output->Calculate feature to calculate these in the past, but the models I am working on are very large, and I want to be able to run the API at night while I go home and the computer cranks away. Here is the code I am using:

Sub Main
Dim App As femap.model
Set App = GetObject(,"femap.model")
Dim s As femap.Set
Dim v As femap.Set
Dim e As femap.Set
Set e = App.feSet
Dim ov As femap.Output
Set ov = App.feOutput
Dim mx As Double
Set mx =App.feOutput
Dim my As Double
Set my = App.feOutput
'Select Output Set and Output Vectors of interest
If App.feSelectOutput("Select Output Vectors",0,FOT_ANY,FOC_ANY,FT_ELEM,False,s,v) = FE_OK Then
If e.Select(FT_ELEM,True, "Select Elements" ) = FE_OK Then
While s.Next()
v.Reset()
While v.Next()
'Calculate Mx'
mx.feOutputCalculate(s.CurrentID(),8,e.CurrentID(),"Mx'","i","Case","(Abs(Vec(!Case;9000003;!i))+Abs(vec(!Case;9000005;!i)))*Abs(vec(!Case;9000003;!i))/vec(!Case;9000003;!i)")
'Calculate My'
my.feOutputCalculate(s,8,e,"My'","i","case","(Abs(Vec(!Case;9000004;!i))+Abs(vec(!Case;9000005;!i)))*Abs(vec(!Case;9000004;!i))/vec(!Case;9000004;!i)")
Wend
Wend
End If
End If
End Sub

The errors I get are on the lines with the feOutputCalculate and are both Invalid Instruction.

Any ideas would be greatly appreciated.

Thanks
 
Replies continue below

Recommended for you

Hello,

Here's a shot at a cleaner version of your code (bottom).
One point needs to be explained: from your code I assumed you use static vector IDs (9000003 4 and 5), meaning for all output sets you have created equivalent output vectors with the same IDs before running this. If this is not the case then my code won't do.

AP


Sub Main
Dim App As femap.model
Set App = feFemap()

Dim s As femap.Set, e As femap.Set

Set s = App.feSet
Set e = App.feSet

'Select Output Set and Output Vectors of interest
If s.SelectMultiID(FT_OUT_CASE,1,"Select OutputSets") = FE_CANCEL Then End
If e.Select(FT_ELEM,True, "Select Elements" ) = FE_CANCEL Then End

While s.Next()
'Calculate Mx'
App.feOutputCalculate(s.CurrentID,FT_ELEM,e.ID,"Mx'","i","Case", _
"(Abs(Vec(!Case;9000003;!i))+Abs(vec(!Case;9000005;!i)))*Abs(vec(!Case;9000003;!i))/vec(!Case;9000003;!i)")

'Calculate My'
App.feOutputCalculate(s.CurrentID,FT_ELEM,e.ID,"My'","i","Case", _
"(Abs(Vec(!Case;9000004;!i))+Abs(vec(!Case;9000005;!i)))*Abs(vec(!Case;9000004;!i))/vec(!Case;9000004;!i)")
Wend
End Sub
 
Thanks APav, I am still playing around with this, though it seems to have a division by zero error that keeps popping up. It looks like vectors 9000003/4 are zero in a lot of spots, but I don't think that is the case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor