Not applicable
01-03-2020
06:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to export the BOM from an assembly using iLogic but it will not read the properties of a virtual component. I make the call to get the description and it gets the part number. This is the code I am using
Dim oDoc As AssemblyDocument oDoc = ThisApplication.ActiveDocument Dim oBOM As BOM oBOM = oDoc.ComponentDefinition.BOM oBOM.PartsOnlyViewEnabled = True oBOM.StructuredViewEnabled = True Dim oBOMView As BOMView oBOMView = oBOM.BOMViews.Item("Structured") xlApp = CreateObject("Excel.Application") 'comment out or change to false 'in order to not show Excel xlApp.Visible = True 'Location of template file xlWorkbook = xlApp.Workbooks.Open("C:\workspace\Export Files\BOM Template.xlsx") xlWorksheet = xlWorkbook.Worksheets.Item("Sheet1") Dim row As Integer row = 5 MyStringParamDesc = iProperties.Value("Project", "Description") MyStringParamAssy = iProperties.Value("Project", "Part Number") xlWorksheet.Range("B1").Value = "DESCRIPTION" xlWorksheet.Range("C1").Value = MyStringParamDesc xlWorksheet.Range("B2").Value = "ASSEMBLY #" xlWorksheet.Range("C2").Value = MyStringParamAssy xlWorksheet.Range("A4").Value = "ITEM" xlWorksheet.Range("B4").Value = "PART #" xlWorksheet.Range("C4").Value = "DESCRIPTION" xlWorksheet.Range("D4").Value = "QTY" 'Dim bRow As bomRow bRows = oBOMView.BOMRows For Each bRow In bRows Dim rDoc As Document rDoc = bRow.ComponentDefinitions.Item(1).Document Dim docPropertySet As PropertySet docPropertySet = rDoc.PropertySets.Item("Design Tracking Properties") xlWorksheet.Range("A" & row).Value = bRow.ItemNumber xlWorksheet.Range("B" & row).Value = docPropertySet.Item("Part Number").Value xlWorksheet.Range("C" & row).Value = docPropertySet.Item("Description").Value xlWorksheet.Range("D" & row).Value = bRow.ItemQuantity row = row + 1 Next 'get BOM target folder path oFolder = "C:\BOM" 'Check for the BOM folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If xlWorkbook.Saveas(oFolder & "\" & MyStringParamAssy & ".xlsx") 'xlWorkbook.Save 'xlWorkbook.Close (False) 'xlApp.Quit
Solved! Go to Solution.
Link copied