I have some code that I'm trying to debug that loops through an assembly and replaces generic named components with SQL database numbers that I pull in a separate function. For components, it works fine. For subassemblies, it does not.
After doing some debugging with my program I decided to record a journal with using Make Unique on a subassembly and it spit out the below. (minus the undo marks) Using this journal works on components without children, does not work on components with children. So there is something missing from the record script and I'm not sure what it is.
Any thoughts?
Edit: After posting this I realized it may have something to do with errors post the builder commit. My test assembly has wavelinks from children in the subassembly to children at the top level, when its replaced via "Make Unique" the links snap. I removed the wavelinks and ran my code and it works on both components with and without children. So now I suppose my question is, what do I do with link updates post builder commit?
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display
Dim makeUniquePartBuilder1 As NXOpen.Assemblies.MakeUniquePartBuilder = Nothing
makeUniquePartBuilder1 = workPart.AssemblyManager.CreateMakeUniquePartBuilder()
Dim component1 As NXOpen.Assemblies.Component = CType(workPart.ComponentAssembly.RootComponent.FindObject("*target comp*"), NXOpen.Assemblies.Component)
Dim added1 As Boolean = Nothing
added1 = makeUniquePartBuilder1.SelectedComponents.Add(component1)
Dim part1 As NXOpen.Part = CType(theSession.Parts.FindObject("*target comp*"), NXOpen.Part)
part1.SetMakeUniqueName("*Assembly dir path*\*New Name*.prt")
Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = makeUniquePartBuilder1.Commit()
makeUniquePartBuilder1.Destroy()
theSession.CleanUpFacetedFacesAndEdges()
End Sub
End Module
