Cancel
Showing results for 
Search instead for 
Did you mean: 

Using API to check if a node is used as dependent node of either a SPC or a MPC.

Valued Contributor
Valued Contributor

Hello, everybody!

 

I have written an API routine to create Multipoint Constraints (MPCs) in my models. I would like to include in this routine a check in order to verify whether there are either rigid elements, SPCs or MPCs using as dependent nodes, the nodes that I have selected as dependent nodes of the MPCs that I would like to create.

Regarding the rigid elements, it was quite simple to write this check and I put hereafter an example of what I did:

 

Imports femap.zMessageColor
Imports femap.zDataType
Imports femap.zGroupDefinitionType
Imports femap.zElementType

Module Module1
    Sub Main()

        'Declare the variables.
        Dim rc As Long

        'Attach to FEMAP.
        Dim App As femap.model
        App = GetObject(, "femap.model")

        'Ask user to select the nodes to check whether they are dependent
        'of rigid elements.
        Dim OpenNdCount As Long
        Dim OpenNdSet As femap.Set
        OpenNdSet = App.feSet()

        rc = OpenNdSet.Select(FT_NODE, True, "Select the Nodes to Check")
        OpenNdCount = OpenNdSet.Count

        'Check whether the selected nodes are used by rigid elements.
        Dim NodeCount As Long
        Dim NdList As Object
        Dim Face As Object
        Dim Weight As Object
        Dim DOF As Object
        Dim ElbyNdSet As femap.Set
        ElbyNdSet = App.feSet()
        Dim RigidElSet As femap.Set
        RigidElSet = App.feSet()
        Dim InterElSet As femap.Set
        InterElSet = App.feSet()
        Dim InterNdSet As femap.Set
        interNdSet = App.feSet()
        Dim DepNdSet As femap.Set
        DepNdSet = App.feSet()
        Dim RigidEl As femap.Elem
        RigidEl = App.feElem()

        ElbyNdSet.AddSetRule(OpenNdSet.ID, FGD_ELEM_BYNODE)
        RigidElSet.AddRule(FET_L_RIGID, FGD_ELEM_BYTYPE)
        InterElSet.AddCommon(ElbyNdSet.ID, RigidElSet.ID)
        If InterElSet.Count > 0 Then
            While InterElSet.Next
                NdList = Nothing
                Face = Nothing
                Weight = Nothing
                DOF = Nothing
                RigidEl.Get(InterElSet.CurrentID)
                RigidEl.GetNodeList(0, NodeCount, NdList, Face, Weight, DOF)
                DepNdSet.AddArray(NodeCount, NdList)
                interNdSet.AddCommon(OpenNdSet.ID, DepNdSet.ID)
                If interNdSet.Count > 0 Then
                    While interNdSet.Next
                        App.feAppMessage(FCM_ERROR, "Node ID " & interNdSet.CurrentID & _
                                 " Is A Dependent Node Of The Rigid Element ID " & _
                                 InterElSet.CurrentID & ".")
                    End While
                End If
                InterNdSet.Reset()
                interNdSet.clear()
                DepNdSet.clear()
            End While
        End If
    End Sub
End Module

 

 

The difficulty that I am experiencing is regarding the check of the SPCs and MPCs. I could think on some possibilities, but they all seemed to be time consuming because they should access FEMAP for each single node, in order to verify whether it was already used as dependent node.

Does somebody have a more elegant (and quick) way to check if a node is already used as a dependent node of either a SPC or a MPC? If so, could post here the code, please?

Remark: I am using Visual Basic 2010 to write my API.

 

Best regards,

 

Fabiano.

6 REPLIES

Re: Using API to check if a node is used as dependent node of either a SPC or a MPC.

Legend
Legend

Dear Fabiano,

 

 

It is possible to speed up your tool. Instead of accessing elements/nodes one by one you need to use GetArray fuction from Element/Node object. It will retrieve all elements/data using one transaction. (much faster).

 

rigids.png

 

We use this method in our tools and it gives very nice performance. This function requires a lot of parameters to read (a bit difficult, but worth the efforts). 

 

if you have difficulties with using this function let me know I will make an example.

 

Yarko

 

 

Re: Using API to check if a node is used as dependent node of either a SPC or a MPC.

Legend
Legend

Dear Fabiano,

 

 

If I understood correctly - you would like to check selected nodes if they are used in rigids. And tool should work quickly.

 

I've made a small demo. To get good performance you should minimize calling Femap functions. Instead of loop through elements/nodes I used GetArray function to retrieve all ids  from set to array (using one call). 

 

rigidNodes.png

 

If you any question about tool performance let me know (I've spend a lot of time with Femap API).

 

Yarko

 

 

Re: Using API to check if a node is used as dependent node of either a SPC or a MPC.

Legend
Legend

Here is an example that can be run in Femap. See attached BAS file.

Re: Using API to check if a node is used as dependent node of either a SPC or a MPC.

Valued Contributor
Valued Contributor

Great post Yarko; I will be using some of this code as part of a similar project. Thank you.

Re: Using API to check if a node is used as dependent node of either a SPC or a MPC.

Legend
Legend

Thanks. I'm happy that it is helpful for you. In case of difficulties let me know maybe I can help. Good luck!

Re: Using API to check if a node is used as dependent node of either a SPC or a MPC.

Legend
Legend

Hi,

 

A tool already exists in Femap Custom tools directory under Model Query / Multi Dependent Rigid Check.

 

Regards,

Seifeddine Naffoussi