' This API highlights all elements of the same type of the selected element ' which are recursively connected to the same element. ' Thus if a plate element is chosen, the API will highlight to the full extent ' of all plate elements sequentially connected to the original plate. Sub Main Dim App As femap.model Set App = feFemap() ' Always in every API to connect API with Femap Dim feElem As femap.Elem Set feElem = App.feElem Dim elID As Long 'Declare and dimension variables Dim Conn_ElSet As femap.Set Set Conn_ElSet = App.feSet Dim Node_Set As femap.Set Set Node_Set = App.feSet Dim El_Type_Set As femap.Set Set El_Type_Set = App.feSet Dim Common_ElSet As femap.Set Set Common_ElSet = App.feSet Dim El_Count As Long El_Count = 1 Dim Old_El_Count As Long Old_El_Count = 0 ' Dim Watchcount As Long ' Dim TypeCount As Long ' Dim Node_Count As Long ' Dim Conn_El_Count As Long rc = App.feViewRegenerate( 0 ) ' Regenerate the Active View ' rc is simply a return code, which can be used to test the success ' of some operations. In this case, the regenerate method provides ' a return code, but the real action is performed by the method itself rc = Conn_ElSet.SelectID(FT_ELEM, "Pick element as start for connected elements of the same type.", elID ) 'Select a single element If rc <> -1 Then Exit Sub End If elID = Conn_ElSet.First() Watchcount = Conn_ElSet.Count rc = feElem.Get(elID) rc = El_Type_Set.AddRule(feElem.type,FGD_ELEM_BYTYPE ) If rc = FE_NOT_EXIST Then Exit Sub End If While El_Count <> Old_El_Count Old_El_Count = El_Count rc = Node_Set.AddSetRule(Conn_ElSet.ID, FGD_NODE_ONELEM) ' Node_Count = Node_Set.Count rc = Conn_ElSet.AddSetRule(Node_Set.ID, FGD_ELEM_BYNODE) ' Conn_El_Count = Conn_ElSet.Count ' Watchcount = Conn_ElSet.Count ' TypeCount = El_Type_Set.Count rc = Common_ElSet.AddCommon(Conn_ElSet.ID, El_Type_Set.ID) El_Count = Common_ElSet.Count Conn_ElSet.Clear() rc = Conn_ElSet.AddSet(Common_ElSet.ID) Common_ElSet.Clear() Wend rc = App.feViewShow( FT_ELEM, Conn_ElSet.ID ) ' Highlight all the connected elements which are of the same type on the screen. Msg = "The total number of highlighted elements is" +Str$( El_Count ) rc = App.feAppMessage(FCM_NORMAL, Msg) rc = Conn_ElSet.Select(FT_ELEM,False, "PRESS OK to ensure this list can be retrived using Previous." ) End Sub