Number of selected components

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.

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. There is some example code in one of your earlier threads that shows one way of doing it:

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

Great, thank you very much.