you can try this iLogic rule. It creates a csv (that you can pen with excel). im in a hurry and i have to go now. But if something is unclear leave a message and i will have a look at it later.
Public Class ThisRule
Private properties As List(Of prop) = New List(Of prop)
Private outputFile As String = "c:\temp\output.csv"
Public Sub main()
' add here more columns as you need them
' for set names and property names see:
' https://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html
properties.Add(New prop("Design Tracking Properties", "Part Number"))
properties.Add(New prop("Design Tracking Properties", "Description"))
Dim doc As AssemblyDocument = ThisDoc.Document
Dim bomView As BOMView = doc.ComponentDefinition.BOM.BOMViews.Item("Structured")
If (IO.File.Exists(outputFile)) Then
IO.File.Delete(outputFile)
End If
createHeader()
writeRows(1, bomView.BOMRows)
End Sub
Private Sub writeRows(parentQty As Integer, rows As BOMRowsEnumerator)
For Each row As BOMRow In rows
writeRowToFile(Row, parentQty)
If (Row.ChildRows IsNot Nothing) Then
writeRows(Row.TotalQuantity, Row.ChildRows)
End If
Next
End Sub
Private Sub createHeader()
Dim values As List(Of String) = New List(Of String)
values.Add("Qty")
For Each item As prop In properties
values.Add(item.propName)
Next
Dim line As String = String.Join(";", values) & System.Environment.NewLine
IO.File.AppendAllText(outputFile, line)
End Sub
Private Sub writeRowToFile(row As BOMRow, parentQty As Integer)
Dim def As ComponentDefinition = row.ComponentDefinitions.Item(1)
Dim doc As Document = def.Document
Dim values As List(Of String) = New List(Of String)
Dim qty As Integer = parentQty * Integer.Parse(row.TotalQuantity)
values.Add(qty.ToString())
For Each item As prop In properties
Dim propSet As PropertySet = doc.PropertySets(item.propSet)
Dim cProperty As [Property] = propSet(item.propName)
values.Add(cProperty.Value)
Next
Dim line As String = String.Join(";", values) & System.Environment.NewLine
IO.File.AppendAllText(outputFile, line)
End Sub
End Class
Public Structure prop
Public Sub New(propSet As String, propName As String)
Me.propSet = propSet
Me.propName = propName
End Sub
Public propSet As String
Public propName As String
End Structure
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog: hjalte.nl - github.com