Sub Main Dim oFAM As New FaceAngleMeasurer(ThisApplication) Dim dAngle As Double = oFAM.GetAngleBetweenFaces(oFace1, oFace2) dAngle = (dAngle * (180 / Math.PI)) 'convert radians to degrees Dim sReport As String = "Angle = " & dAngle.ToString & " deg" If oFAM.FacesAreParallel Then sReport &= vbCrLf & "Faces were parallel" MsgBox(sReport, vbInformation, "iLogic") End Sub Class FaceAngleMeasurer Private _InvApp As Inventor.Application Private _FacesAreParallel As Boolean Sub New(InventorApp As Inventor.Application) _InvApp = InventorApp End Sub Public Function GetAngleBetweenFaces(Optional oFace1 As Inventor.Face = Nothing, _ Optional oFace2 As Inventor.Face = Nothing) As Double If oFace1 Is Nothing Then oFace1 = PickPlanarFace If oFace1 Is Nothing Then Return 0.0 If oFace2 Is Nothing Then oFace2 = PickPlanarFace If oFace2 Is Nothing Then Return 0.0 Dim oNorm1 As UnitVector = GetFaceNormal(oFace1) Dim oNorm2 As UnitVector = GetFaceNormal(oFace2) If oNorm1.IsParallelTo(oNorm2) Then _FacesAreParallel = True Return 0.0 Else Dim oEdgeDirection As UnitVector = oNorm1.CrossProduct(oNorm2) Dim oAngleDir1 As UnitVector = oNorm1.CrossProduct(oEdgeDirection) Dim oAngleDir2 As UnitVector = oEdgeDirection.CrossProduct(oNorm2) Return oAngleDir1.AngleTo(oAngleDir2) End If Return 0.0 End Function Private Function PickPlanarFace(Optional sPrompt As String = Nothing) As Inventor.Face If sPrompt Is Nothing OrElse sPrompt = "" Then sPrompt = "Select Planar Face - or press ESC key to exit" Dim eFilter As SelectionFilterEnum = SelectionFilterEnum.kPartFacePlanarFilter Dim oFace As Face = _InvApp.CommandManager.Pick(eFilter, sPrompt) Return oFace End Function Private Function GetFaceNormal(oFace As Inventor.Face) As Inventor.UnitVector If TypeOf oFace.Geometry Is Inventor.Plane Then Dim oPlane As Inventor.Plane = oFace.Geometry Return oPlane.Normal Else Dim oPt() As Double = {} : Dim oNorm() As Double = {} oFace.PointOnFace.GetPointData(oPt) oFace.Evaluator.GetNormalAtPoint(oPt, oNorm) Return _InvApp.TransientGeometry.CreateUnitVector(oNorm(0), oNorm(1), oNorm(2)) End If End Function Public ReadOnly Property FacesAreParallel As Boolean Get Return _FacesAreParallel End Get End Property End Class