×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

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

Jobs

Femap API code, Groups from Layers

Femap API code, Groups from Layers

Femap API code, Groups from Layers

(OP)
Hi All,
First I'd like to say hello to everyone. This is my first post here.

Would you kindly advise what is wrong with this piece of code?
Working with Femap 11.
I try to create groups based on information from layers. I started from surfaces and found incomprehensible problem at once.
API creates groups but somehow it summing up surfaces IDs from previous step. Looks like clear function is ignored but no. IDs listed in each step are correct.
For single layer (no loop) api works correctly. Thank in advance.
Tadeusz

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

Dim layer_ As femap.layer
Set layer_ = App.feLayer

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

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

Dim layerName As String
Dim layerID As Long
Dim group_ID As Long

While layer_.Next 'go throgh all layers
If (layer_.ID <> 1) And (layer_.ID <> 9999) Then ' exluding these
'take layer
layer_.Get(layer_.ID)
layerName = layer_.title
App.feAppMessage(FCM_NORMAL, "Working on layer :" & Str(layer_.ID) &"=>" & " " & layerName )

surfOnLayer_set.Clear()
surfOnLayer_set.AddEntitiesOnLayer( -(layer_.ID), FT_SURFACE) ' collect surfaces in the set

' time to create group
group_ID = group_.NextEmptyID
group_.Get(group_ID)
group_.title = layerName
group_.SetAdd(FT_SURFACE, surfOnLayer_set.ID) ' add surfaces from the set
group_.Put(group_ID)

End If
Wend

End Sub

RE: Femap API code, Groups from Layers

Hi,

Your problem is that you clear the set but not the group! Think of the group as a "set of sets", or rather a double vector with a rule on one side, and a list of IDs on the other.

You never clear you group therefore the surfaces are cumulated in it.

The easiest way to do this is to re-set it each time, cf code below.

AP


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

Dim layer_ As femap.layer
Set layer_ = App.feLayer

Dim group_ As femap.Group

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

While layer_.Next 'go throgh all layers
If (layer_.ID <> 1) And (layer_.ID <> 9999) Then ' exluding these
App.feAppMessage(FCM_NORMAL, "Working on layer :" & Str(layer_.ID) &"=>" & " " & layer_.title )

surfOnLayer_set.Clear
surfOnLayer_set.AddEntitiesOnLayer( -layer_.ID, FT_SURFACE) ' collect surfaces in the set

'time to create group
Set group_ = App.feGroup
group_.title = layer_.title
group_.SetAdd(FT_SURFACE, surfOnLayer_set.ID) ' add surfaces from the set
group_.Put(group_.NextEmptyID)
End If
Wend
End Sub

RE: Femap API code, Groups from Layers

(OP)
Just great. Thanks a lot.

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!


Resources