Forums:
I am looking for a way to get all the component objects that have solid material in a certain point3d. Is this possible?
Below is a script that collects the positions of the selected parts. The idea is to create a new point on an offset of the found position and check if there is a component on that spot and get thats component name.
Option Strict Off Imports System Imports System.Collections.Generic Imports NXOpen Imports NXOpenUI Imports NXOpen.UF Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim theUI As UI = UI.GetUI Dim lw As ListingWindow = theSession.ListingWindow If IsNothing(theSession.Parts.BaseWork) Then 'active part required Return End If Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects() Dim theComps As New List(Of Assemblies.Component) lw.Open() For i As Integer = 0 To numsel - 1 Dim selObj As TaggedObject = theUI.SelectionManager.GetSelectedTaggedObject(i) If TypeOf (selObj) Is Assemblies.Component Then theComps.Add(selObj) Dim pt As NXOpen.Point3d Dim mx As NXOpen.Matrix3x3 theComps.Item(i).GetPosition(pt, mx) Dim axisZ As New NXOpen.Vector3d(mx.Zx, mx.Zy, mx.Zz) lw.WriteLine(theComps.Item(i).Name) lw.WriteLine( "; Position = " & pt.ToString) lw.WriteLine( "; AxisZ = " & axisZ.ToString & vbCr) End If Next If theComps.Count = 0 Then 'no components found among the preselected objects lw.WriteLine("no components found among the preselected objects") Return End If My.Computer.Clipboard.SetText(theComps.Item(0).Name) lw.WriteLine("Selected Objects: " & theComps.Item(0).Name) End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image immediately after execution within NX GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately End Function End Module