Cancel
Showing results for 
Search instead for 
Did you mean: 

FEMAP API GroupAutomaticAdd is view regenerate necessary

Creator
Creator

Hi,

 

I'm writing a simple API which revolves elements on a curve and then associates these newly created shell elements to a surface. To acheive this I create a new group, activate Group Automatic Add for this group, revolve the elements on curve, then associate the elements in the group to a selected surface.

 

I've noticed that the elements won't appear in the group unless I include a feViewRegenerate before attempting to select them by group and associate to the surface (using .AddGroup to an element set, and then feMeshAttach).

 

When using Group Automatic Add (App.Info_GroupAutomaticAdd =groupID), in a FEMAP API, is it necessary to call feViewRegenerate before elements appear in the group (or am I doing something wrong) ?

 

 

Is this the correct approach?

 

Thanks

 

Fergus

 

4 REPLIES

Re: FEMAP API GroupAutomaticAdd is view regenerate necessary

Siemens Genius Siemens Genius
Siemens Genius

I just recreated this and did not need an feViewRegenerate for the elements to appear in the group. Could you possibly post your code? 

Re: FEMAP API GroupAutomaticAdd is view regenerate necessary

Creator
Creator

Thank you for your help.

 

Bizarrely I can't recreate the error today. So must have been some logic error in my code. 

 

 

Re: FEMAP API GroupAutomaticAdd is view regenerate necessary

Creator
Creator

OK, correction I am getting this problem again !

 

In the attached API if I do not include the line "App.ViewRegenerate(0)", then my group will not have any elements in it. But if I have this function call after the revolve mesh, and before the 'associate mesh to surface by group', it will work correctly and the elements will be added to the group.

 

Can anyone explain why this may be?

 

 

This is my API below:

 

The HTML Clipboard

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

' The purpose of this API is to assist with creating a revolved shell element model
' Before running this API the model needs to have surfaces created
' and mesh size set on lines to revolve
' This API will mesh a curve, revolve the mesh about Z-axis, and associate to a selected surface

Dim elSet As Object
Set elSet =App.feSet

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

Dim curveID As Long
rc=curveSet.SelectID(FT_CURVE,"Please Select Curve to revolve",curveID)
If rc <> FE_OK Then Exit Sub

Dim surfaceSet As femap.Set
Set surfaceSet = App.feSet
Dim surfaceID As Long

rc=surfaceSet.SelectID(FT_SURFACE,"Please Select Surface to associate mesh to",surfaceID)
If rc <> FE_OK Then Exit Sub

Dim pr As Object
Set pr = App.feProp
pr.SelectID("Select Solid Property ID")

Dim message As String

Dim groupEntity As Object
Set groupEntity=App.feGroup
Dim groupID As Long
Dim groupName As String
groupName = InputBox("Enter name for group(s)","group name")
If groupName = "" Then
App.feAppMessage(0,"ERROR - group name required !")
 Exit Sub
End If

'create New Group
groupID=groupEntity.NextEmptyID
groupEntity.title = groupName
groupEntity.SetAdd(FT_SURFACE,surfaceSet.ID)
groupEntity.Put(groupID)
App.Info_GroupAutomaticAdd =groupID

'Mesh Curve
Dim orient(2) As Double
orient(0)=1
orient(1)=0
orient(2)=0

rc=App.feMeshCurve(curveSet.ID,True,-1,orient)
If rc = FE_OK Then
message = "Meshed curve "+CStr(curveID)
App.feAppMessage(0,message)
Else
    Stop
End If

Dim angle As Double
re=App.feGetReal("Enter angle of rotation", -360, 360, angle)
If rc = FE_CANCEL Then Exit Sub

Dim nume As Long
rc=App.feGetInt("Enter the number of elements", 1, 32767, nume)
If rc = FE_CANCEL Then Exit Sub

Dim axisBase(2) As Double
axisBase(0)=0
axisBase(1)=0
axisBase(2)=0

Dim axisVec(2) As Double
axisVec(0)=0
axisVec(1)=0
axisVec(2)=1

Dim angleVec(2) As Double
angleVec(0)=angle
angleVec(1)=0
angleVec(2)=0

'Revolve mesh
rc = App.feMeshRevolveCurve(curveSet.ID,angle,0,axisBase,axisVec,pr.ID,nume)

'App.feViewRegenerate (0) 'seems to be required here to update group before adding elements from group to element set

'Associate mesh to surface by group
rc = elSet.AddGroup(FT_ELEM ,groupID) 'add all shell elements just created to selection set elSet
messsage = "elSet size is " + CStr(elSet.Count)
App.feAppMessage(0,message)
rc= App.feMeshAttach(FT_ELEM,elSet.ID,FT_SURFACE,surfaceID,True)

'turn Off auto add To Group
App.Info_GroupAutomaticAdd = 0

End Sub

Re: FEMAP API GroupAutomaticAdd is view regenerate necessary

Siemens Phenom Siemens Phenom
Siemens Phenom

This one certainly is not an obvious problem or solution. Sorry about that.  

 

When you use Automatic Add to update a Group FEMAP doesn't really update the group immediately as new entities are created. Unfortunately that would be very inefficient and a significant performance problem. Instead, we keep a record of everything that is created or deleted and at the end of a command this information gets processed to update the group. It is also used at the same time to update all of the various panes  such as the Model Info Tree.

 

When you are doing this from the middle of an API, you haven't technically reached the "end of a command" so that record just keeps building up.  It would be processed eventually, but not in time for what you were expecting. By calling App.ViewRegenerate(0) you are simply forcing that to be done when you need it. 

 

There is another, probably better, way to make this work. I will say, that I haven't really tried it, but I believe it should work. Try replacing App.ViewRegenerate(0) with App.feUpdatePanes( FALSE ).  This should process the records and get your group updated. It will update the panes, but should not force a regenerate.

 

Hope this helps.