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!

Getting the number of the element of a group

Status
Not open for further replies.

rbas85

Structural
Sep 23, 2019
7
I'm new to FEMAP API tools. I'd like to know how can I get the number of the elements of a group. I'm asking that because I'd like to loop through all elements of a determined group, save the number of these elements on a sheet and get their properties. I'm posting my code below:
Sub external_pressure_load()
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Sheets("ExternalPressure")
Dim App As femap.Model
Set App = GetObject(, "femap.model")
Dim grp As femap.Group
Set grp = App.feGroup
Dim olel As femap.Set
Set olel = App.feSet
Dim grID As Long
Dim elID As Long
Dim i As Long
Dim el As femap.Elem
Set el = App.feElem

While grp.Next
grpID = grp.ID
If grpID = 3 Then
rc = olel.Clear()
rc = olel.AddGroup(FT_ELEM, grID)
elID = olel.First()
MsgBox grpID
i = 1
Do While elID > 0
rc = el.Get(elID)
ws1.Range("A" & i) = el
i = i + 1
elID = olel.Next()
Loop
End If
Wend
End Sub
 
Replies continue below

Recommended for you

you could renumber the elements in the group (possibly temporarily),
you could export the group as an analysis model.

another day in paradise, or is paradise one day closer ?
 
Thanks! I found out my error. In "rc = olel.AddGroup(FT_ELEM, grID)", I should have written "grpID" instead of "grID".
 
If you want the total number of elements in a group, the easiest way is to just use the selector toolbar... Change selector entity to elements, change the selector mode to multiple. Make sure only the group you want is posted. Hold shift and click and drag to grab everything in the window. The total number of elements selected will be listed in the Model Info Pane under Selection List.
 
Hi rbas85,
if you did an external FEMAP API program and has plenty (hundred thousand) of elements in your group, your loop based on olel.Next() can slow down the program execution speed/time. So if you will meet such an issue, you can try to use el.GetAllArray(... ) method. This method records all elements IDs (and other elements data) from the set to regular 2D array and it can increase program speed up to x10 times. I've met it a few times, especially for water static pressure application macro tool.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor