rbas85
Structural
- Sep 23, 2019
- 7
I'm trying to get the Von Mises Stress of elements 1 to 50, but my API code is not working. I get the error "run-time error 13 – Type mismatch". Follow a code that I copied from Iberisa to get what I want:
Sub Main()
Dim App As femap.Model
Set App = GetObject(, "femap.model")
Dim fOS As femap.OutputSet
Dim fOV As femap.Output
Dim fsElem As femap.Set
Dim nArr As Long
Dim i As Long
Dim values As Variant
Dim ents As Variant
Dim rc As Long
Set fOS = App.feOutputSet
Set fsElem = App.feSet
fOS.Get (1)
Set fOV = fOS.Vector(7033)
rc = fsElem.AddRange(1, 50, 1)
rc = fsElem.GetArray(nArr, ents)
rc = fOV.GetScalarAtElemSet(fsElem.ID, values)
For i = 0 To nArr - 1 Step 1
rc = App.feAppMessage(FCM_NORMAL, "Element ID: " + Str$(ents(i)) + _
", Top VM Stress: " + Str$(values(i)))
Next
End Sub
The line with problem is rc = App.feAppMessage(FCM_NORMAL, "Element ID: " + Str$(ents(i)) + ", Top VM Stress: " + Str$(values(i))). Apparently, the variable "values" is not declared correctly, but I don't know what to do.
Sub Main()
Dim App As femap.Model
Set App = GetObject(, "femap.model")
Dim fOS As femap.OutputSet
Dim fOV As femap.Output
Dim fsElem As femap.Set
Dim nArr As Long
Dim i As Long
Dim values As Variant
Dim ents As Variant
Dim rc As Long
Set fOS = App.feOutputSet
Set fsElem = App.feSet
fOS.Get (1)
Set fOV = fOS.Vector(7033)
rc = fsElem.AddRange(1, 50, 1)
rc = fsElem.GetArray(nArr, ents)
rc = fOV.GetScalarAtElemSet(fsElem.ID, values)
For i = 0 To nArr - 1 Step 1
rc = App.feAppMessage(FCM_NORMAL, "Element ID: " + Str$(ents(i)) + _
", Top VM Stress: " + Str$(values(i)))
Next
End Sub
The line with problem is rc = App.feAppMessage(FCM_NORMAL, "Element ID: " + Str$(ents(i)) + ", Top VM Stress: " + Str$(values(i))). Apparently, the variable "values" is not declared correctly, but I don't know what to do.