' This API finds all the "dependent" nodes (from RBE elements) which are only ' connected to a single element - ie. RBE elements with floating nodes. ' It is also finds the elements belonging to those nodes. ' The API is currently hard coded to clear and recreate Group 41 for the nodes & els. ' The API is hard coded to find RBE (element type 29), but could be Sub Main Dim App As femap.model Set App = feFemap() Dim feNode As femap.Node Set feNode = App.feNode ' These define the node object. Dim feElem As femap.Elem Set feElem = App.feElem Dim elSet As femap.Set Set elSet = App.feSet ' These define an element object , and a set to collect element object ' elSet is later used to select all elements of a type. Dim elsndSet As femap.Set Set elsndSet = App.feSet ' This element set will be used to collect the elements on the floating RBE nodes. Dim ndSet As femap.Set Set ndSet = App.feSet ' 'These define a set-of-nodes object ' This node set is all the nodes on the elements in elset. Dim gr41 As Group Set gr41 = App.feGroup Dim grID As Long ' grID = 41 ' NOTE: THE GROUP ID CAN BE ANY preferably unused ID. ' The contents of this group are cleared and re-populated each time the API is run. gr41.Get(grID) gr41.title = "Nodes of RBEs conected to only one element" gr41.Put(grID) gr41.RangeDeleteAll(-1) ' This creates gr41 as a group. ' and specifies the Group ID as an integer. ' and specifies the Group ID = 41 ' and clears the group of its contents. Dim ndID As Long 'This is used to identify the nodes in the node set. Dim indID As Long ' This is used to identify the RBE independent node. Dim Count As Long Count = 0 ' This is a cumulative counter to find how many nodes satisfy the criteria. rc = elSet.Clear() rc = ndSet.Clear() ' Make sure the node set and element set are clear. ' rc simply represents a return code, sometimes used to test success of operation. rc = elSet.AddRule(29,FGD_ELEM_BYTYPE) ' Populate the element set with elements by Type 29 = rigid ' The API COULD EASILY BE CHANGED to OTHER ELEMENT TYPES. If rc<>-1 Then App.feAppMessage(FCM_ERROR, "Error Selecting Elements") Exit Sub End If ' If there is any error populating the elset with elements, then exit rc = ndSet.AddSetRule( elSet.ID, FGD_NODE_ONELEM ) ' Then populate the node set with nodes belonging to the element set If rc<>-1 Then App.feAppMessage(FCM_ERROR, "Error Selecting Nodes on Rigid Elements") Exit Sub End If ' If there is any error populating the elset with elements, then exit Dim numels As Long numels = elSet.Count() ' Numels is simply the number of elements in the element set. msg = "There are" + Str$(numels) + " RBE elements in total" rc = App.feAppMessage(FCM_NORMAL, Str$(msg)) ' Show how many elements . ie. rigid elements, in the set. msg = "There are" + Str$(ndSet.Count()) + " total nodes on RBE elements" rc = App.feAppMessage(FCM_NORMAL, Str$(msg)) ' Inform the user how many nodes are on RBE elements. Dim elemID As Long elemID = elSet.First() ' go to the first element in the set and load its id. While elemID > 0 rc = feElem.Get(elemID) ' load the element. indID = feElem.Node(0) ' find node zero, which for an RBE is the single node = independent for RBE2 rc = ndSet.Remove(indID) ' take this node out of the node set, as it is OK for this node to only be connected to 1 element. elemID = elSet.Next() ' increment to the next rigid element and loop back up to find its node. Wend msg = "There are" + Str$(ndSet.Count()) + " total nodes on RBE elements, excluding RBE2 independent and RBE3 dependent nodes." rc = App.feAppMessage(FCM_NORMAL, Str$(msg)) ' Inform the user how many RBE nodes are legs of the spider rather than body of the spider, ndID=ndSet.First() ' Then specify ndID as being the id of the first node in the set While ndID > 0 ' Loop around from the first to last Node ID in the node set. rc = feNode.Get(ndID) ' Load the feNode object with the data from Node ndID. ' NOTE, THE THRESHOLD NUMBER BELOW CAN BE CHANGED. If feNode.NumberOfElements < 2 Then ' If the node is connected to only one element then Count=Count+1 ' Increment the cumulative count of nodes with only one element connected rc = elsndSet.AddRule(ndID,FGD_ELEM_BYNODE) ' Also find the element belonging to the node gr41.Add(FT_NODE,ndID) ' Add the node to the group gr41.SetAdd(8,elsndSet.ID) ' Add the element to the group Msg = "Node" +Str$(feNode.ID) +" has" + Str$(feNode.NumberOfElements) + " element connected." ' Populate the Msg variable with the ID of the Node and text. rc = App.feAppMessage(FCM_NORMAL, Msg) ' Send the Msg to the Messages Window as normal text. End If ndID = ndSet.Next() 'Increment the Node ID to the next in the Node Set Wend ' Loop back up to where the next node data is loaded. gr41.Put(grID) ' Save the group into the Femap database. rc =ndSet.Clear() ' Clear all the ids from the Node Set rc =ndSet.AddGroup(FT_NODE, grID) ' Add back into the Node Set all the nodes in the Group (#41), which ' are now only the non-connected nodes. msg = "There are" + Str$(ndSet.Count()) + " floating nodes on RBE elements." rc = App.feAppMessage(FCM_NORMAL, Str$(msg)) ' Inform the user how many floating nodes there are. msg = "There are a total of" + Str$(elsndSet.Count) + " RBE elements with floating nodes." rc = App.feAppMessage(FCM_NORMAL, Str$(msg)) ' Inform the user how many elements belong to the floating nodes. End Sub