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

Getting the number of the element of a group

Getting the number of the element of a group

Getting the number of the element of a group

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()
End If
End Sub

RE: Getting the number of the element of a group

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 ?

RE: Getting the number of the element of a group

Thanks! I found out my error. In "rc = olel.AddGroup(FT_ELEM, grID)", I should have written "grpID" instead of "grID".

RE: Getting the number of the element of a group

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.

RE: Getting the number of the element of a group

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.

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! Already a Member? Login


White Paper - PLM and ERP: Their Respective Roles in Modern Manufacturing
Leading manufacturers are aligning their people, processes, and tools from initial product ideation through to field service. They do so by providing access to product and enterprise data in the context of each person’s domain expertise. However, it can be complicated and costly to unite engineering with the factory and supply chain. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close