2 Replies Latest reply on Feb 18, 2015 4:16 PM by Keith Rice

    Way to determine if 2 faces share a common edge

    Drew Miller

      Using VBA, SW2014. 

       

      Have 2 Faces, need to find whether they share edge.  I have tried using swmodel.closestdistance (thinking this will be zero  or at least very small if they share an edge).

      Would like to know if there is an easier way to do this

       

      Thanks

        • Re: Way to determine if 2 faces share a common edge
          Drew Miller

          Wrote a function to try and do this- seems to work but there's probably an easier way?

           

          Function SharedEdge(Face_1 As SldWorks.Face2, Face_2 As SldWorks.Face2) As Boolean

              Dim vEdgeArr        As Variant

              Dim vEdge           As Variant

              Dim vFace           As Variant

              Dim adjacentFace1   As SldWorks.Face2

              Dim adjacentFace2   As SldWorks.Face2

              Dim swEdge          As SldWorks.Edge

              Dim boolValue       As Boolean

             

              vEdgeArr = Face_1.GetEdges  '  Face_2 is the one to compare to

             

              For Each vEdge In vEdgeArr

                  Set swEdge = vEdge

                   swEdge.Display 2, 1#, 0#, 0#, True  'highlight edges

                  

                  vFace = swEdge.GetTwoAdjacentFaces2

                  Set adjacentFace1 = vFace(0)

                  Set adjacentFace2 = vFace(1)

                  swEdge.Display 0, 0#, 0#, 0#, False  'turn off highlighting

                If (adjacentFace1.IsSame(Face_2) Or adjacentFace2.IsSame(Face_2)) Then

                  SharedEdge = True

                  Exit Function

                Else

                  SharedEdge = False

                End If

                 

              Next vEdge

             

          End Function