Solid Edge Part Type Library
MeasureDistance Method
Specifies the first element from which the minimum distance is to be measured.
Specifies the second element from which the minimum distance is to be measured.
Specify the type of distance to be measured.
Returns the distance between Element1 and Element2.
Returns dX value. This is the distance calculated  along X axis between the point1 on Element1 that is closest to point2 on Element2.
Returns dY value. This is the distance calculated  along Y axis between the point1 on Element1 that is closest to point2 on Element2.
Returns dZ value. This is the distance calculated along Z axis between the point1 on Element1 that is closest to point2 on Element2.
Returns the point on Element1 that is closest to Element2.
Returns the point on Element2 that is closest to Element1.
Description
Measures the distance between two elements.
Syntax
Visual Basic
Public Sub MeasureDistance( _
   ByVal Element1 As Object, _
   ByVal Element2 As Object, _
   ByVal DistanceType As MeasureDistanceTypeConstants, _
   ByRef Distance As Double, _
   ByRef DX As Double, _
   ByRef DY As Double, _
   ByRef DZ As Double, _
   ByRef Point1() As Double, _
   ByRef Point2() As Double _
) 
Parameters
Element1
Specifies the first element from which the minimum distance is to be measured.
Element2
Specifies the second element from which the minimum distance is to be measured.
DistanceType
ValueDescription
MeasureDistanceTypeConstants_MaximumDistance
MeasureDistanceTypeConstants_MinimumDistance
MeasureDistanceTypeConstants_SmartDistance
Specify the type of distance to be measured.
Distance
Returns the distance between Element1 and Element2.
DX
Returns dX value. This is the distance calculated  along X axis between the point1 on Element1 that is closest to point2 on Element2.
DY
Returns dY value. This is the distance calculated  along Y axis between the point1 on Element1 that is closest to point2 on Element2.
DZ
Returns dZ value. This is the distance calculated along Z axis between the point1 on Element1 that is closest to point2 on Element2.
Point1
Returns the point on Element1 that is closest to Element2.
Point2
Returns the point on Element2 that is closest to Element1.
Example
Imports System.IO
Imports System.Runtime.InteropServices

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim objApp As SolidEdgeFramework.Application
        Dim objPartDoc As SolidEdgePart.PartDocument = Nothing
        Dim objDocuments As SolidEdgeFramework.Documents = Nothing
        Dim objFolder As DirectoryInfo
        Dim objFileInfo As FileInfo
        Dim distance As Double
        Dim dx As Double
        Dim dy As Double
        Dim dz As Double
        Dim dgoem(2) As Double
        Dim featedges As SolidEdgeGeometry.Edges
        Dim featedge1 As SolidEdgeGeometry.Edge
        Dim featedge2 As SolidEdgeGeometry.Edge
        Dim featedge3 As SolidEdgeGeometry.Edge
        Dim objFace1 As SolidEdgeGeometry.Face
        Dim objFace2 As SolidEdgeGeometry.Face
        Dim dblPoint1(0) As Double
        Dim dblPoint2(0) As Double
        Dim dblPoint3(0) As Double
        Dim angle1 As Double
        Dim angle2 As Double
        Dim angle3 As Double
        Dim angle4 As Double
        Dim SurfArea As Double
        Dim Volume As Double
        Dim Length As Double
        Dim coSyss As SolidEdgePart.CoordinateSystem

        dgoem(0) = 0
        dgoem(1) = 0
        dgoem(2) = 0

        Try
            objApp = Marshal.GetActiveObject("SolidEdge.Application")
            objFolder = GetTrainingFolder()
            objFileInfo = New FileInfo(Path.Combine(objFolder.FullName, "anchor.par"))
            objDocuments = objApp.Documents
            objPartDoc = objDocuments.Open(objFileInfo.FullName)
            objFace1 = objPartDoc.Models.Item(1).ExtrudedProtrusions.Item(1).Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll).Item(1)
            objFace2 = objPartDoc.Models.Item(1).ExtrudedProtrusions.Item(1).Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll).Item(2)

            Call objPartDoc.MeasureDistance(objFace1, objFace2, SolidEdgePart.MeasureDistanceTypeConstants.MeasureDistanceTypeConstants_MaximumDistance, distance, dx, dy, dz, dblPoint1, dblPoint2)
            MsgBox("Distance between the elements is " + distance.ToString)
            featedges = objPartDoc.Models.Item(1).ExtrudedProtrusions.Item(2).Edges(SolidEdgeConstants.FeatureTopologyQueryTypeConstants.igQueryAll)
            featedge1 = featedges.Item(18)
            featedge2 = featedges.Item(19)
            featedge3 = featedges.Item(20)
            Call objPartDoc.MeasureAngleEx(featedge1, featedge2, featedge3, angle1, angle2, angle3, angle4)
            MsgBox("Angle between the edges is " + Math.Round(RadiansToDegrees(angle1)).ToString + " degrees")

            Call objPartDoc.InquireElement(featedge1, dgoem, Nothing, dblPoint1, SurfArea, Volume, Length)

            coSyss = objPartDoc.CoordinateSystems.Item(1)

            Call objPartDoc.InquireElement(featedge1, dblPoint2, coSyss, dblPoint3, SurfArea, Volume, Length)
            MsgBox("Length of Inquired Element is " + Length.ToString)
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
            Clipboard.SetText(ex.ToString)
        End Try
    End Sub
    Private Function RadiansToDegrees(ByVal radians As Double) As Double
        Return radians * (180 / Math.PI)
    End Function
    Function GetTrainingFolder() As DirectoryInfo
        Dim objInstallData As SEInstallDataLib.SEInstallData = Nothing
        Dim objInstallFolder As DirectoryInfo = Nothing
        Dim objTrainingFolder As DirectoryInfo = Nothing

        Try
            objInstallData = New SEInstallDataLib.SEInstallData
            objInstallFolder = New DirectoryInfo(objInstallData.GetInstalledPath())
            objTrainingFolder = New DirectoryInfo(Path.Combine(objInstallFolder.Parent.FullName, "Training"))
        Catch
        Finally
            If Not (objInstallData Is Nothing) Then
                Marshal.FinalReleaseComObject(objInstallData)
                objInstallData = Nothing
            End If
        End Try

        Return objTrainingFolder
    End Function


End Class
See Also

PartDocument Object  | PartDocument Members