Cancel
Showing results for 
Search instead for 
Did you mean: 

Number Of Selected Components using NX Open

Creator
Creator

I am wondering how to find out the number of selected components. I can access the first, second, and so on selected part using:

 

(NXOpen.Assemblies.Component)theUI.SelectionManager.GetSelectedTaggedObject(0)

(NXOpen.Assemblies.Component)theUI.SelectionManager.GetSelectedTaggedObject(1)

...

However, I don't know how find the number of selected components.

 

Thanks in advnace.

2 REPLIES

Re: Number Of Selected Components using NX Open

Phenom
Phenom

Try:

theUI.SelectionManager.GetNumSelectedObjects()
Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | KF
Production: [NX8.5.3.3 MP11 64bit] Testing: [NX12.0.0.27 MP1]

Re: Number Of Selected Components using NX Open

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

The selection manager has a .GetNumSelectedObjects method that will tell you how many objects are currently selected. Note that these objects could be anything, it doesn't tell you whether the object is a component or not. To get the number of components, you will need to sort through the selected objects to see how many are components. Some example code can be found here:

 

http://nxjournaling.com/comment/2955#comment-2955