I am currently doing a journal to export assembly to excel and it is working except for the order in the navigation window. I want the exported data to follow the same order in the navigation window.
Here is part of my code
For Each child_component As Component In Component_.GetChildren() 'some more code here getcomponent_info(child_component, indent + 2) Next
The GetChildren method gives the order of the output but it is not the same with the navigation window.
Can anybody direct me how to order my parts in the assembly as in the navigation window?
Thank you very much
Where did you search? I went to the Solution Centre and searched using the suggested string and found exactly 1 API program dealing with your issue.
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | KF
Production: [NX188.8.131.52 MP11 64bit] Testing: [NX184.108.40.206 MP1]
My apology , I think I search the wrong place.
The solution here seems to work on NX10. We are still on NX9. I have read somewhere that AskChildrenOrder does not work properly on NX9. Can you confirm?
For NX 9 you can try GetChildrenOrder, which is deprecated in NX 10.
Production: NX10.0.3, VERICUT 8.1, FBM, MRL 3.1.7 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk Testing: NX12.0 Preparing: NX12.0
Employees of the customers, together we are strong
How to Get the Most from Your Signature in the Community
NX Customization - Best Practice Guide
I modified the code posted above to use getchildrenOrder instead of askchildrenorder and got this error.
I do not know what this error is. bellow is the code I use to test
Imports System Imports NXOpen Imports NXOpen.UF Module NXJournal Dim theSession As Session = Session.GetSession() Dim theUFSession As UFSession = UFSession.GetUFSession() Dim workPart As Part = theSession.Parts.Work Public Sub Main(ByVal args As String()) Dim displayPart As Part = theSession.Parts.Display Dim markId1 As NXOpen.Session.UndoMarkId = theSession.SetUndoMark( NXOpen.Session.MarkVisibility.Visible, "Reorder Components") Dim theOrders As Assemblies.ComponentOrder() = Nothing displayPart.ComponentAssembly.GetComponentOrders(theOrders) ' GetActiveOrder is new in NX10.0.3 'Dim theCurrentOrder As Assemblies.Order = 'displayPart.ComponentAssembly.GetActiveOrder() 'Echo("The current Component Order is " & theCurrentOrder.Name) Echo(displayPart.Leaf & " has " & theOrders.Length & " ComponentOrder objects") For Each anOrder As Assemblies.ComponentOrder In theOrders anOrder.Activate() theSession.UpdateManager.DoUpdate(markId1) Echo(anOrder.Name & ":") WalkAssemblyTree(displayPart.ComponentAssembly.RootComponent, anOrder, "") theUFSession.Ui.DisplayMessage(anOrder.Name, 1) theSession.UndoToMark(markId1, "") Next theSession.DeleteUndoMarksUpToMark(markId1, "", False) End Sub Sub WalkAssemblyTree(ByVal theComponent As NXOpen.Assemblies.Component, ByVal theOrder As NXOpen.Assemblies.ComponentOrder, ByVal indent As String) Dim kids As Assemblies.Component() = theComponent.GetChildren() If kids.Length = 0 Then Return ' Not an assembly or sub-assembly indent = indent + " " ' This does not always work - see PR 7487277 ' Testing in the Toycar assembly only Chronological returns any Children 'kids = theOrder.AskChildrenOrder(theComponent.directowner) theOrder.getchildrenorder(theComponent.directowner, kids) For ii As Integer = 0 To kids.Length - 1 Echo(indent & kids(ii).DisplayName) WalkAssemblyTree(kids(ii), theOrder, indent) Next End Sub Sub Echo(ByVal output As String) theSession.ListingWindow.Open() theSession.ListingWindow.WriteLine(output) theSession.LogFile.WriteLine(output) End Sub Public Function GetUnloadOption(ByVal arg As String) As Integer Return Session.LibraryUnloadOption.Immediately End Function End Module
I tested the code you posted and I did not get any error message. But the 'kids' component array was empty for all component orders. Seems to be a bug in NX9.
It has been fixed in NX10. The first parameter for GetChildrenOrder has to be a Component rather than a ComponentAssembly.
I think there is a substancial change in NX9 going to NX10.
As commented in the code the AskChildrenOrder method does not even work properly for all order type.
Does the askchildrenorder works in NX10 properly?