'NX 4.0.4.2 Option Strict Off Imports System Imports NXOpen Imports NXOpen.UI Imports NXOpen.Utilities Imports NXOpen.UF Module select_two_curve_01 Dim s As Session = Session.GetSession() Dim ufs As UFSession = UFSession.GetUFSession() Dim lw As ListingWindow = s.ListingWindow Dim workPart As Part = s.Parts.Work Sub Main() Dim curve1 As NXOpen.Tag Dim curve2 As NXOpen.Tag lw.Open() While select_a_curve1(curve1) = Selection.Response.Ok Dim spline1 As NXObject = Nothing Dim splineData1 As UFCurve.Spline = Nothing ufs.Curve.AskSplineData(curve1, splineData1) If select_a_curve2(curve2) = Selection.Response.Ok Then Dim spline2 As NXObject = Nothing Dim splineData2 As UFCurve.Spline = Nothing ufs.Curve.AskSplineData(curve1, splineData1) Dim nullUnit1 As Unit = Nothing Dim measureDistance1 As MeasureDistance measureDistance1 = workPart.MeasureManager.NewDistance(nullUnit1, MeasureManager.MeasureType.Minimum, spline1, spline2) Dim WertMeasure1 As Double = measureDistance1.Value.ToString() lw.WriteLine(WertMeasure1) End If End While ufs.Disp.SetHighlight(curve1, 0) ufs.Disp.SetHighlight(curve2, 0) End Sub Function select_a_curve1(ByRef curve As NXOpen.Tag) As Selection.Response Dim message As String = "Curves:" Dim title As String = "erste Kurve auswählen" Dim scope As Integer = UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY Dim response As Integer Dim view As NXOpen.Tag Dim cursor(2) As Double Dim sel_mask As UFUi.SelInitFnT = AddressOf mask_for_curve ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM) Try ufs.Ui.SelectWithSingleDialog(message, title, scope, sel_mask, _ Nothing, response, curve, cursor, view) Finally ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM) End Try If response <> UFConstants.UF_UI_OBJECT_SELECTED And _ response <> UFConstants.UF_UI_OBJECT_SELECTED_BY_NAME Then Return Selection.Response.Cancel Else Return Selection.Response.Ok End If End Function Function select_a_curve2(ByRef curve As NXOpen.Tag) As Selection.Response Dim message As String = "Curves:" Dim title As String = "zweite Kurve auswählen" Dim scope As Integer = UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY Dim response As Integer Dim view As NXOpen.Tag Dim cursor(2) As Double Dim sel_mask As UFUi.SelInitFnT = AddressOf mask_for_curve ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM) Try ufs.Ui.SelectWithSingleDialog(message, title, scope, sel_mask, _ Nothing, response, curve, cursor, view) Finally ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM) End Try If response <> UFConstants.UF_UI_OBJECT_SELECTED And _ response <> UFConstants.UF_UI_OBJECT_SELECTED_BY_NAME Then Return Selection.Response.Cancel Else Return Selection.Response.Ok End If End Function Function mask_for_curve(ByVal select_ As IntPtr, _ ByVal userdata As IntPtr) As Integer Dim num_triples As Integer = 5 Dim mask_triples(4) As UFUi.Mask mask_triples(0).object_type = UFConstants.UF_line_type mask_triples(0).object_subtype = 0 mask_triples(0).solid_type = 0 mask_triples(1).object_type = UFConstants.UF_circle_type mask_triples(1).object_subtype = 0 mask_triples(1).solid_type = 0 mask_triples(2).object_type = UFConstants.UF_conic_type mask_triples(2).object_subtype = 0 mask_triples(2).solid_type = 0 mask_triples(3).object_type = UFConstants.UF_spline_type mask_triples(3).object_subtype = 0 mask_triples(3).solid_type = 0 mask_triples(4).object_type = UFConstants.UF_point_type mask_triples(4).object_subtype = 0 mask_triples(4).solid_type = 0 ufs.Ui.SetSelMask(select_, _ UFUi.SelMaskAction.SelMaskClearAndEnableSpecific, _ num_triples, mask_triples) Return UFConstants.UF_UI_SEL_SUCCESS End Function Public Function GetUnloadOption(ByVal dummy As String) As Integer Return Session.LibraryUnloadOption.Immediately End Function End Module