Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a iLogic script that I am having trouble getting the .IAM Structured BOM to export to Excel with "All Levels". I have searched and I am not able to find a solution. I know it is something I am overlooking.
Could anyone take a look and give me some advice?
Code:
'Export Folder location oPATH = ("C:\Desktop\") 'Copy Template Excel / Copied File Excel Dim oExcelTemp As String = String.Concat ("C:\Desktop\ExportTemp.xlsx") Dim oBOMName As String = String.Concat(oPATH + ThisDoc.FileName(False) + ".xlsx") Try IO.File.Copy(oExcelTemp, oBOMName, True) Catch ex As Exception MessageBox.Show(ex.Message) End Try Dim oDoc As AssemblyDocument oDoc = ThisApplication.ActiveDocument Dim oBOM As BOM oBOM = oDoc.ComponentDefinition.BOM 'Import BOM Custom Layout oBOM.ImportBOMCustomization("C:\Desktop\Temp_BOM.xml") ' edit this line to point to the exported XML 'STRUCTURED BoM oBOM.StructuredViewEnabled = True Dim oStructuredBOMView As BOMView oBOM.StructuredViewFirstLevelOnly = False oStructuredBOMView = oBOM.BOMViews.Item ("Structured") 'PARTS ONLY BoM 'oBOM.PartsOnlyViewEnabled = True 'Dim oPartsOnlyBOMView As BOMView 'oPartsOnlyBOMView = oBOM.BOMViews.Item("Parts Only") xlApp = CreateObject("Excel.Application") 'comment out or change to false in order to not show Excel xlApp.Visible = True xlWorkbook = xlApp.Workbooks.Open(oBOMName) xlWorksheet = xlWorkbook.Worksheets.Item("Engineering") Dim row As Integer row = 3 xlWorksheet.Range("A2").Value = "ITEM" xlWorksheet.Range("B2").Value = "Part Number" xlWorksheet.Range("C2").Value = "UNIT" xlWorksheet.Range("D2").Value = "QTY" xlWorksheet.Range("E2").Value = "DESCRIPTION" xlWorksheet.Range("F2").Value = "REV" xlWorksheet.Range("G2").Value = "MATERIAL" xlWorksheet.Range("H2").Value = "LENGTH" xlWorksheet.Range("I2").Value = "SHEET METAL LENGTH" xlWorksheet.Range("J2").Value = "SHEET METAL WIDTH" xlWorksheet.Range("K2").Value = "PRECENT" xlWorksheet.Range("L2").Value = "ROUTER ID" 'Dim bRow As bomRow bRows = oStructuredBOMView.BOMRows 'bRows = oPartsOnlyBOMView.BOMRows For Each bRow In bRows Dim rDoc As Document rDoc = bRow.ComponentDefinitions.Item(1).Document Dim docPropertySet As PropertySet Dim oCustomPropSet As PropertySet Dim oSumPropertySet As PropertySet docPropertySet = rDoc.PropertySets.Item("Design Tracking Properties") oCustomPropSet = rDoc.PropertySets.Item("Inventor User Defined Properties") oSumPropertySet = rDoc.PropertySets.Item("Summary Information") Try xlWorksheet.Range("A" & row).Value = bRow.ItemNumber xlWorksheet.Range("B" & row).Value = docPropertySet.Item("Part Number").Value xlWorksheet.Range("C" & row).Value = "EA" xlWorksheet.Range("D" & row).Value = bRow.ItemQuantity xlWorksheet.Range("E" & row).Value = docPropertySet.Item("Description").Value xlWorksheet.Range("F" & row).Value = oSumPropertySet.Item("Revision Number").Value xlWorksheet.Range("G" & row).Value = docPropertySet.Item("Material").Value xlWorksheet.Range("H" & row).Value = oCustomPropSet.Item("Length").Value xlWorksheet.Range("I" & row).Value = oCustomPropSet.Item("SheetMetalLength").Value xlWorksheet.Range("J" & row).Value = oCustomPropSet.Item("SheetMetalWidth").Value xlWorksheet.Range("K" & row).Value = oCustomPropSet.Item("PERC").Value xlWorksheet.Range("L" & row).Value = oCustomPropSet.Item("ROUTER").Value Catch ex As Exception 'MessageBox.Show(ex.Message) End Try row = row + 1 Next xlWorkbook.Save xlWorkbook.Close (True) xlApp.Quit i = MessageBox.Show("Would you like to preview the BOM?", "iLogic”, MessageBoxButtons.YesNo) If i = vbYes Then : launchviewer = 1 : Else : launchviewer = 0 : End If If launchviewer = 1 Then ThisDoc.Launch(oBOMName)
Solved! Go to Solution.