@C_Haines_ENG,
Here is an example where I hide all other bodies. Not sure if you still need them to be highlighted at that point, but I left it in:
Sub Main
Dim pDoc As PartDocument = TryCast(ThisApplication.ActiveDocument, PartDocument)
If IsNothing(pDoc) Then Logger.Debug("Active Document is not: " & CType(pDoc.Type, ObjectTypeEnum).ToString)
Dim selectThis As HighlightSet = pDoc.CreateHighlightSet
Dim AllBodies As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
For Each sb As SurfaceBody In pDoc.ComponentDefinition.SurfaceBodies
AllBodies.Add(sb)
Next
For Each oSolid As SurfaceBody In pDoc.ComponentDefinition.SurfaceBodies
AllBodies.RemoveByObject(oSolid)
Call HideAll(AllBodies, False)
selectThis.AddItem(oSolid)
MessageBox.Show("Solid Selected", "Pause for Action")
selectThis.Clear
Call HideAll(AllBodies, True)
AllBodies.Add(oSolid)
Next
End Sub
Sub HideAll(BodyCol As ObjectCollection, Visibility As Boolean)
For Each sb As SurfaceBody In BodyCol
sb.Visible = Visibility
Next
End Sub
The only way to use the UI "HideOthers" command is through ControlDefinitions, which I'm not a fan of, but it could look like this:
Sub Main
Dim pDoc As PartDocument = TryCast(ThisApplication.ActiveDocument, PartDocument)
If IsNothing(pDoc) Then Logger.Debug("Active Document is not: " & CType(pDoc.Type, ObjectTypeEnum).ToString)
Dim selectThis As HighlightSet = pDoc.CreateHighlightSet
Dim selSet As SelectSet = pDoc.SelectSet
Dim HideOthers As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("HideOtherBodiesCtxCmd")
Dim ShowAll As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("ShowAllBodiesCtxCmd")
For Each oSolid As SurfaceBody In pDoc.ComponentDefinition.SurfaceBodies
selSet.Select(oSolid)
HideOthers.Execute
selectThis.AddItem(oSolid)
MessageBox.Show("Solid Selected", "Pause for Action")
selectThis.Clear
selSet.Remove(oSolid)
Next
ShowAll.Execute
End Sub
Let me know if you have any questions