Option Strict Off
Imports System
Imports System.Collections
Imports NXOpen
Imports NXOpen.Assemblies
Imports NXOpen.UF
Module ReportReferenceSet
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim lw As ListingWindow = s.ListingWindow
Dim displaypart As Part = s.Parts.Display
Sub Main()
Dim allComp1 As ArrayList = New ArrayList
' lw.Open()
Dim root As Component = s.Parts.Display.ComponentAssembly.RootComponent
getAllComponents2(root, allComp1)
Dim referenceSet1 As String = "Entire Part"
Dim referenceSet2 As String = "S"
' reportComponentReferenceSet(allComp1, referenceSet1)
ChangeComponentReferenceSet(allComp1, referenceSet1, referenceSet2)
End Sub
Sub reportComponentReferenceSet(ByVal allComp1 As ArrayList, ByVal referenceSet1 As String)
For Each comp As Component In allComp1
If comp.ReferenceSet = referenceSet1 Then
lw.WriteLine(comp.Name & " " & comp.ReferenceSet)
End If
Next
End Sub
Sub ChangeComponentReferenceSet(ByVal allComp1 As ArrayList, ByVal referenceSet1 As String, _
ByVal referenceSet2 As String)
Dim errorList1 As ErrorList
Dim comp1(0) As Component
For Each comp As Component In allComp1
If comp.ReferenceSet = referenceSet1 Then
comp1(0) = comp
errorList1 = displaypart.ComponentAssembly.ReplaceReferenceSetInOwners(referenceSet2, comp1)
End If
Next
End Sub
Sub getAllComponents2(ByVal comp As Component, ByRef allComp As ArrayList)
Dim child As Component = Nothing
Dim space As String = Nothing
For Each child In comp.GetChildren()
allComp.Add(child)
getAllComponents2(child, allComp)
Next
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
End Module