This VBA script in Femap aligns the normals of beam and bar elements to the normals of adjacent plate elements. It selects the relevant beam/bar and plate/shell properties, identifies the connected beam and plate elements, calculates the average normal of connected plates, and reorients the beam element normal to match. Finally it regenerates the model view.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
243 views3 pages
Align Beams To Connected Shells
This VBA script in Femap aligns the normals of beam and bar elements to the normals of adjacent plate elements. It selects the relevant beam/bar and plate/shell properties, identifies the connected beam and plate elements, calculates the average normal of connected plates, and reorients the beam element normal to match. Finally it regenerates the model view.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3
Sub Main
Dim App As femap.model
Set App = feFemap() Dim alignPropSET As femap.Set Set alignPropSET = App.feSet Dim normalPropSET As femap.Set Set normalPropSET = App.feSet rc = alignPropSET.Select( FT_PROP, True, "Select Line Element Properties to Align Normal to Plates" ) Dim feProp As femap.Prop Set feProp = App.feProp rc = feProp.Reset() rc = alignPropSET.Reset() While feProp.NextInSet( alignPropSET.ID ) = FE_OK Select Case feProp.type Case femap.FET_L_BEAM Case femap.FET_L_BAR Case Else Msg = "Removing Non Bar/Beam Properties" rc = App.feAppMessage( FCM_NORMAL, Msg ) rc = alignPropSET.Remove( feProp.ID ) End Select Wend If alignPropSET.Count = 0 Then Msg = "No Beam or Bar Properties Selected, Exiting..." rc = App.feAppMessage( FCM_NORMAL, Msg ) GoTo JUMP_OUT End If rc = normalPropSET.Select( FT_PROP, True, "Select Plate Properties to Align Beams Normal To" ) rc = feProp.Reset() rc = normalPropSET.Reset() While feProp.NextInSet( normalPropSET.ID ) = FE_OK Select Case feProp.type Case femap.FET_L_PLATE Case femap.FET_L_LAMINATE_PLATE Case Else Msg = "Removing Non Plate/Shell Properties" rc = App.feAppMessage( FCM_NORMAL, Msg ) rc = normalPropSET.Remove( feProp.ID ) End Select Wend If normalPropSET.Count = 0 Then Msg = "No Plate/Shell Properties Selected, Exiting..." rc = App.feAppMessage( FCM_NORMAL, Msg ) GoTo JUMP_OUT End If Dim beamSET As femap.Set Set beamSET = App.feSet Dim shellSET As femap.Set Set shellSET = App.feSet Dim ndSET1 As femap.Set Dim ndSET2 As femap.Set Set ndSET1 = App.feSet Set ndSET2 = App.feSet Dim connectedElementSET As femap.Set Set connectedElementSET = App.feSet Dim connectedPlateSET As femap.Set Set connectedPlateSET = App.feSet rc = beamSET.AddSetRule( alignPropSET.ID, FGD_ELEM_BYPROP ) rc = shellSET.AddSetRule( normalPropSET.ID, FGD_ELEM_BYPROP ) If beamSET.Count = 0 Then Msg = "No Beams to Process, Exiting...." rc = App.feAppMessage( FCM_NORMAL, Msg ) End If Dim feElem As femap.Elem Set feElem = App.feElem Dim feELem2 As femap.Elem Set feELem2 = App.feElem Dim ndCommonSET As femap.Set Set ndCommonSET = App.feSet rc = beamSET.Reset() rc = feElem.Reset() Dim nVec(2) As Double Dim nConn As Long Dim elNorm As Variant Dim vLength As Double While feElem.NextInSet( beamSET.ID ) = FE_OK nConn = 0 nVec(0) = 0.0 nVec(1) = 0.0 nVec(2) = 0.0 rc = ndSET1.Clear rc = ndSET1.Add( feElem.Node(0) ) rc = ndSET1.Add( feElem.Node(1) ) rc = connectedElementSET.Clear rc = connectedElementSET.AddSetRule( ndSET1.ID, FGD_ELEM_BYNODE ) rc = connectedPlateSET.Clear rc = connectedPlateSET.AddCommon( shellSET.ID, connectedElementS ET.ID ) rc = connectedPlateSET.Reset rc = feELem2.Reset While feELem2.NextInSet( connectedPlateSET.ID ) = FE_OK rc = ndSET2.Clear rc = ndSET2.AddRule( feELem2.ID, FGD_NODE_ONELEM ) rc = ndCommonSET.Clear rc = ndCommonSET.AddCommon( ndSET1.ID, ndSET2.ID ) If ndCommonSET.Count = 2 Then rc = feELem2.GetFaceNormal( 1, elNorm ) nVec(0) = nVec(0) - elNorm(0) nVec(1) = nVec(1) - elNorm(1) nVec(2) = nVec(2) - elNorm(2) nConn = nConn + 1 End If Wend If nConn > 0 Then vLength = 0.0 rc = App.feVectorLength( nVec, vLength ) nVec(0) = nVec(0) / vLength nVec(1) = nVec(1) / vLength nVec(2) = nVec(2) / vLength If vLength > 0.0 Then 'rc = App.feModifyOrient( -feElem.ID, 1, 0, nVec ) feElem.orient(0) = nVec(0) feElem.orient(1) = nVec(1) feElem.orient(2) = nVec(2) rc = feElem.Put( feElem.ID ) End If End If Wend rc = App.feViewRegenerate( 0 ) JUMP_OUT: End Sub