iLogic not reading properties of virtual component

This widget could not be displayed.

iLogic not reading properties of virtual component

Anonymous
Not applicable

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
0 Likes
Reply
Accepted solutions (1)
856 Views
1 Reply
Reply (1)

dg2405
Advocate
Advocate
Accepted solution

VirtualComponents aren't realy documents. The iProperties for them can you get with:

bRow.ComponentDefinitions(1).PropertySets("Design Tracking Properties")("Part Number").Value   

 But first you have to distinguish between virtual and non-virtual components:

If TypeOf bRow.ComponentDefinitions(1) Is VirtualComponentDefinition Then