Export Orderd Assembly BOM to Excel

Hi,

I am using the Export Assembly to Excel that exist in this forum but now in NX11 we can change the assembly component structure order.
but the list that I get in excel is not the current order.

How can we get the ComponentAssembly list with the current active order.

Best Regard,
Amir

That's exactly the same as I'm currently searching for! I hope somebody has got a clue on this...
Stefan

Working with the component order is not too difficult; the code below shows how to get the order, change the order, and list the top level components in the current order. This code could be expanded upon and added to the Excel BOM code to do what you want.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()

Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()

Dim displayPart As Part = theSession.Parts.Display

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")

lw.Open()

Dim theOrders As Assemblies.ComponentOrder() = Nothing
displayPart.ComponentAssembly.GetComponentOrders(theOrders)

lw.WriteLine("initial component order: " & displayPart.ComponentAssembly.GetActiveOrder.Name)
lw.WriteLine("")

lw.WriteLine(displayPart.Leaf & " has " & theOrders.Length & " ComponentOrder objects")
lw.WriteLine("")

For Each anOrder As Assemblies.ComponentOrder In theOrders

anOrder.Activate()
lw.WriteLine("new active order: " & displayPart.ComponentAssembly.GetActiveOrder.Name)
lw.WriteLine(" order type: " & anOrder.OrderType.ToString)
lw.WriteLine(" order state: " & anOrder.OrderState.ToString)

Dim orderedComponents() As Assemblies.Component
orderedComponents = anOrder.AskChildrenOrder(displayPart.ComponentAssembly.RootComponent)

For Each tempComp As Assemblies.Component In orderedComponents
lw.WriteLine(" " & tempComp.DisplayName)
Next
lw.WriteLine("")

Next

lw.Close()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module

Code tested with NX 11.

Thanks for that!
However, does anyone happen to know how to achieve that in NX8.5? Unfortunately, NXOpen.Assemblies.ComponentOrder() doesn't exist there...

Thanks in advance!
Stefan

This is not possible in NX 8.5; the "component order" option was first introduced in NX 9, but it had issues. The bugs were fixed in NX 10; that is the first release where the journal code will work reliably.