Here, is the code. Just run an new Inventor application, open a empty part, add a iLogic rule, paste the code and GO.
It will ask to point to the folder. So you shouldn't make any edits to the code.
The excel files with the exported are saved in the same folder with the same name as the assembly.
I didn't add a progress bar.. you can monitor the progress by watching the folder.
If the assembly has unresolved documents, it will not export a BOM to excel. Just so you know..
Imports System.Windows.Forms
Imports System.IO
Public Sub Main
Dim oPath As String
' Search for the folder
Dim Dialog = New FolderBrowserDialog()
Dialog.ShowNewFolderButton = True
Dialog.Description = "Jef_E Bom's export tool"
' Show dialog box
If DialogResult.OK = Dialog.ShowDialog() Then
' User clicked 'ok' on dialog box - capture the export path
oPath = Dialog.SelectedPath & "\"
Else
' User clicked 'cancel' on dialog box - exit
Return
End If
' Make a reference to a directory.
Dim oDirectoryInfo As New DirectoryInfo(oPath)
' Get a reference to each file in that directory.
Dim oFileArray As FileInfo() = oDirectoryInfo.GetFiles()
' Display the names of the files.
Dim oFileInfo As FileInfo
' Loop through all files in the directory (not in the sub directories.)
For Each oFileInfo In oFileArray
If oFileInfo.Name.contains(".iam") Then
' Open the file
ThisApplication.Documents.Open(oFileInfo.FullName, True)
' Export the BOM
' Set a reference to the assembly document.
' This assumes an assembly document is active.
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
' Set a reference to the BOM
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM
' Set the structured view to 'all levels'
oBOM.StructuredViewFirstLevelOnly = False
' Make sure that the structured view is enabled.
oBOM.StructuredViewEnabled = True
' Set a reference to the "Structured" BOMView
Dim oStructuredBOMView As BOMView
oStructuredBOMView = oBOM.BOMViews.Item("Structured")
Dim oExcelPath As String
oExcelPath = oPath & System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName)& ".xls"
' Export the BOM view to an Excel file
oStructuredBOMView.Export(oExcelPath, kMicrosoftExcelFormat)
' Close the document
oDoc.Close
End If
Next
End Sub
Please kudo my posts and accept as solution.
Please kudo if this post was helpfull
Please accept as solution if your problem was solved
Inventor 2014 SP2