Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Better way to highlight a selected Solid Body by its solidBody.ToString

Let's assume I want to highligh the

solidBody.ToString = "Solid 12345"

I can use

            For Each solidBody As Snap.NX.Body In Snap.Globals.WorkPart.Bodies
                If solidBody.ToString =  "Solid 12345" Then
                    solidBody.IsHighlighted = True
                End If
            Next

However, this is not very efficient as I have to loop through all the solid bodies. Is there any better way?

 

 

 

1 REPLY
Solution
Solution
Accepted by topic author ulink2rle
‎03-03-2017 11:11 AM

Re: Better way to highlight a selected Solid Body by its solidBody.ToString

If "Solid123" is the name of the body, then write:

 

 Dim obj = Snap.NX.NXObject.FindByName("Solid123")
obj.IsHighlighted = True

Internally, the code will still cycle through the part file looking for "Solid123", though. This is not very efficient, but, depending on what you're doing, you may not notice the inefficiency.

 

 

Be careful ... feature names and body names are two different things, so you have to think a bit about which one you're using.

 

There is usually no need for this "FindByName" stuff. Usually, you already have a program variable that refers to the object you want to highlight (because you created it, or the user selected it, for example). So, I'd recommend that you take another look at your code, and see if you already have the object you need.

山田
yamada