Cancel
Showing results for 
Search instead for 
Did you mean: 

API to create contact/connector

Pioneer
Pioneer

Hello, I have a a bunch of meshes created through automation. Some meshes are associative to surface and others were imported as neutral files. My initial idea was to use feConnectAuto2 to create connector using surfaces. But with mixture of ways the meshes were created, it is only partially helping. Is there a way to create connector thru API between orphan meshes similar to how feconnectAuto2 works. Appreciate any ideas.

 

Thank you.

1 REPLY

Re: API to create contact/connector

Siemens Phenom Siemens Phenom
Siemens Phenom

You can make use of the ".AddConnectedElements()" method on Femap Set objects.  Below is an example script that uses feConnectAuto2 then creates contact regions on elements that have not been automatically connected.  You could also check the element associativity to realize if the mesh is an orphan.

 

Orphan_Contact_Region.gif

 

 


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

    Dim solidSet As Set
    Set solidSet = App.feSet

    Dim tol As Double
    solidSet.AddAll(FT_SOLID)
    connectType = 0
    tol = 200.0
    ang = 360.0
    strategy = 5
    SelfConnect = False
    CombineAll = True
    ConnectProp = 0
    Glued = False
    rc = App.feConnectAuto2(solidSet.ID,connectType,tol,ang,strategy,SelfConnect,CombineAll,ConnectProp,Glued)
    App.feViewRegenerate(0)

    entity = FT_ELEM

    Dim connectSet As Set
    Dim elemsConnected As Set
    Dim eSet As Set
    Dim NoContactEntitySet As Set
    Dim keepEntitySet As Set
    Dim e As Elem
    Dim reg As ConnectionRegion

    Set connectSet = App.feSet
    Set elemsConnected = App.feSet
    Set eSet = App.feSet
    Set NoContactEntitySet = App.feSet
    Set keepEntitySet = App.feSet
    Set e = App.feElem
    Set reg = App.feConnectionRegion

        'Create Region Variables
    Dim listcount As Long
    Dim listType() As Long, entityVar() As Long
    Dim faceVar() As Long, expandVar() As Long
    Dim normalXYZ As Variant

    NoContactEntitySet.AddAll(entity)
    connectSet.AddAll(FT_CONTACT)

    While connectSet.Next()
        reg.Get(connectSet.CurrentID)
        Set eSet = reg.GetEntitySet(entity,True)
            'Keep a set of all entites that do not have connections
        NoContactEntitySet.RemoveSet(eSet.ID)
    Wend

    count = 0
    eSet.Clear()
    While NoContactEntitySet.Next()
        eSet.Clear()
        eSet.Add(NoContactEntitySet.CurrentID)
        rc = FE_OK
        While True
            eSet.AddConnectedElements()
            If eSet.Count - count = 0 Then
                Exit While
            End If
            count = eSet.Count()
                'Wait and Show are uneccesary, can comment out
            Wait 0.05
            eSet.Show(entity)
        Wend
        ReDim listType(eSet.Count)
        ReDim entityVar(eSet.Count)
        ReDim faceVar(eSet.Count)
        ReDim expandVar(eSet.Count)

        i = 0
        eSet.Reset()
        While eSet.Next()
            e.Get(eSet.CurrentID)
            e.GetFaceNormal(3,normalXYZ)
            listType(i) = entity
            entityVar(i) = eSet.CurrentID
            faceVar(i) = 1
            expandVar(i) = 0
            i += 1
        Wend
        regID = reg.NextEmptyID()

        rc = reg.PutContactList(i,listType,entityVar,faceVar,expandVar)
        rc = reg.Put(regID)
            'Update the model info Tree
        App.feAppUpdatePanes(True)
        NoContactEntitySet.RemoveSet(eSet.ID)
        NoContactEntitySet.Reset()
    Wend

    App.feViewRegenerate(0)

End Sub