BOM Export

BOM Export

Anonymous
Not applicable
440 Views
3 Replies
Message 1 of 4

BOM Export

Anonymous
Not applicable

Hello!

 

I have a mild issue regarding the BOM export part QTY.

My main assembly consists of 3 sub-assemblies. Inventor BOM only shows the QTY of one sub-assembly and QTY of one sub-assembly parts.

Is there somekind of a iLogic solution, so I could export the BOM with the qty of 3 assemblies?

I also attached the picture with the issue in here. Anyone can help me out please?

0 Likes
441 Views
3 Replies
Replies (3)
Message 2 of 4

JelteDeJong
Mentor
Mentor

Its possible to create an iLogic rule to do that. Its dificult beacuse you need to export it first to excel. Then change the excel file. In most cases if you need the total numbers then you can use the "Parts only bom". It will show total numbers of all parts. It works perfect as a list of parts that you need to purchase. Did you have a look at the "Parts only bom"?

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.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thank you for the answer.

Yes, I have had a look at the "Parts Only" BoM. It's basically one of the solutions to my problem. Of course, this means double work, because usually my BoM list is about 200 rows long.

This is the main issue, why I was hoping, that there is a iLogic solution to it.

0 Likes
Message 4 of 4

JelteDeJong
Mentor
Mentor

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.

EESignature


Blog: hjalte.nl - github.com

0 Likes