Cancel
Showing results for 
Search instead for 
Did you mean: 

How to read Group IDs generated by a function

Creator
Creator

Hi,

 

Fegroupgenerate generated a bunch of groups. Now i'm trying to create one element set for every group created. How to determine the group IDs created by the function?

 

Thanks

Krish Matty

11 REPLIES

Re: How to read Group IDs generated by a function

Legend
Legend

Dear Krish,

 

 

There are 2 methods to do that:

1) using set difference

2) using track object

 

I will describe first one because it's easy and works in every femap version and track objects appeared in latest ones.

 

The idea is following: you create set and fill with all groups, run functions that generates groups, create one more set, fill with all groups and substract first set:


    Dim groupBeforeSet As femap.Set
    Set groupBeforeSet = App.feSet
    groupBeforeSet.AddAll(FT_GROUP)

    'function that generates groups

    Dim groupAfterSet As femap.Set
    Set groupAfterSet = App.feSet
    groupAfterSet.AddAll(FT_GROUP)
    groupAfterSet.RemoveSet(groupBeforeSet.ID)

 

Yarko

Re: How to read Group IDs generated by a function

Legend
Legend

Dear Krish,

 

 

Second method using TrackData. Similar to method with sets:

    Dim trackObject As femap.TrackData
    Set trackObject = App.feTrackData

    trackObject.Start(FT_GROUP)

    'call group generation function

    trackObject.Stop(FT_GROUP)

    Dim groupSet As femap.Set
    Set groupSet =App.feSet

    trackObject.Created(FT_GROUP, groupSet.ID, True)

 

TrackData has some nice methods: trackObject.Deleted - get ids of deleted items, StartMesh/StartGeometry - track all mesh/geomety.

 

Choose method you prefer

 

Yarko

Re: How to read Group IDs generated by a function

Creator
Creator
Thanks a lot Yarko. Very helpful.

Re: How to read Group IDs generated by a function

Creator
Creator
Yarko, I would like to create element set for every group in a groupset. How do i go abt it?

I used groupset.getarray(numID, ID) to get the number of groups & group ID in a group set.

With more than 100 groups in my groupset, i would like create create element set for each group. could you please direct?

Thanks
Krish

Re: How to read Group IDs generated by a function

Phenom
Phenom

You need to look at the Group Object in the API docs for this one (section 5.31 for Femap Version 11.1 and 11.2).  The List method is probably what you need or the GetList method.

 

Something along the lines of indexing through the ID's in your groupset, then "getting" the group, and then

Set setname feGroup.List(8)

 

Note that List Type "8" refers to elements.

Also note that this is one of the cases where the API pdf shows an excellent example for the Group Obect ->List method which covers exactly what you need.

In your case, you will probably want to index through a range of element sets as you index through your groupset, so that you create an element set for each group in your group set.

Re: How to read Group IDs generated by a function

Legend
Legend

Dear Krish,

 

 

You need to create array of sets to read elements for every group and using List method from group fill every set. Here is an example (sets(i) - array of sets with elements):

 

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

        Dim groupBeforeSet As femap.Set
    Set groupBeforeSet = App.feSet
    groupBeforeSet.AddAll(FT_GROUP)

    'function that generates groups

    Dim groupAfterSet As femap.Set
    Set groupAfterSet = App.feSet
    groupAfterSet.AddAll(FT_GROUP)
    groupAfterSet.RemoveSet(groupBeforeSet.ID)

    Dim groupCount As Long
    Dim groupIds As Variant

    'get group ids
    groupAfterSet.GetArray(groupCount, groupIds)

    Dim fgroup As femap.Group
    Set fgroup = App.feGroup

    'create array of sets and define dimension = groupCount
    Dim sets() As femap.Set
    ReDim sets(groupCount)

    'fill sets with group ids
    For i = 0 To groupCount -1
        fgroup.Get(groupIds(i))
        Set sets(i) = fgroup.List(zGroupDataType.FGR_ELEM)
    Next

End Sub

 

Yarko

Re: How to read Group IDs generated by a function

Creator
Creator

Thank you for your direction! I have an idea now.

Re: How to read Group IDs generated by a function

Creator
Creator
Thank you again Yarko.

Re: How to read Group IDs generated by a function

Creator
Creator

Group data type is FGR_ELEM. so it should be
Set sets(i) = fgroup.List(FGR_ELEM) or Set sets(i) = fgroup.List(8) ...

I get "method or property not found"

 

I also tried with fgroup.list(zgroupdatatype.FGR_ELEM).

 

FEMAP help shows it needs to be list(groupdatatype) which is what i have. Am i overlooking something?

 

Thanks