Imports System Imports NXOpen Imports NXOpen.UF Imports NXOpenUI Imports NXOpen.Utilities Module select_by_id Dim sess As Session = Session.GetSession() Dim ufs As UFSession = UFSession.GetUFSession Dim lw As ListingWindow = sess.ListingWindow Dim wp As Part = sess.Parts.Work Dim sm As Selection = UI.GetUI.SelectionManager Sub Main() lw.Open() lw.WriteLine("------------------------------------------") Dim prefix As String = "HANDLE R-" ' Objekt auswählen, ID ausgeben Dim crv As NXObject = select_curve() If Not crv Is Nothing Then Dim jid As String = crv.JournalIdentifier.Replace(prefix, "") lw.WriteLine("Object ID " & jid) End If ' ID abfragen Dim idstr As String = prefix Dim obj As NXObject = Nothing Try Dim id As Double = NXInputBox.GetInputNumber("Enter ID") idstr &= id.ToString Catch ex As Exception lw.WriteLine("Invalid input") End Try lw.WriteLine("Looking for " & idstr) ' Typen antesten Try obj = wp.Lines.FindObject(idstr) lw.WriteLine("Object Type is Line") Catch ex As NXException lw.WriteLine(ex.Message.Replace("object", "Line").Replace("name", "id")) End Try Try obj = wp.Arcs.FindObject(idstr) lw.WriteLine("Object Type is Arc") Catch ex As NXException lw.WriteLine(ex.Message.Replace("object", "Arc").Replace("name", "id")) End Try Try obj = wp.Splines.FindObject(idstr) lw.WriteLine("Object Type is Spline") Catch ex As NXException lw.WriteLine(ex.Message.Replace("object", "Spline").Replace("name", "id")) End Try ' Objektinfo ausgeben If Not obj Is Nothing Then Dim obj_arr() As NXObject = {obj} sess.Information.DisplayObjectsDetails(obj_arr) End If End Sub Private Function select_curve() As NXObject Dim type_arr() As Selection.SelectionType = {Selection.SelectionType.CurvesAndEdges} Dim obj As NXObject = Nothing Dim cursor As Point3d Dim sel_resp As Selection.Response = sm.SelectObject("Select a Curve", _ "Select Curve", Selection.SelectionScope.AnyInAssembly, _ False, type_arr, obj, cursor) If sel_resp < 4 Then Return Nothing Else Return obj End If End Function End Module