Hi all,
I made a short bom query based in sample in API help.
I have assembly which has one promoted assembly in the structured BOM (among the other normal components).
If I run my test macro in Inventor everything is going fine.
But if I run almost the similar code in Apprentice server, when it comes to the promoted row it cannot create ComponentDefinition to the row.
I think this is a bug in Apprentice server?
Has anyone else had this problem?
regards,
Matti
Here's code in inventor VBA:
Sub test2()
Dim oApprentice As New ApprenticeServerComponent
' Open a document.
Dim oBOM As BOM
Set oBOM = ThisApplication.ActiveDocument.ComponentDefinition.BOM
' oBOM.StructuredViewEnabled = True
' oBOM.StructuredViewFirstLevelOnly = True
Dim oBOMView As BOMView
Set oBOMView = oBOM.BOMViews.Item("Structured")
Dim oRow As BOMRow
Dim i As Long
For i = 1 To oBOMView.BOMRows.Count
Set oRow = oBOMView.BOMRows.Item(i)
Dim oCompDef As ComponentDefinition
Dim oPropSet As PropertySet
' If oRow.Promoted = False Then
Set oCompDef = oRow.ComponentDefinitions.Item(1)
Set oPropSet = oCompDef.Document.PropertySets.Item("Design Tracking Properties")
Debug.Print ("-: " & oRow.ItemNumber & " Quantity:" & oRow.ItemQuantity & "Part: " & oPropSet.Item("Part Number").Value & " Desc: " & oPropSet.Item("Description").Value)
' Else
'get filename
' End If
'gets the primoted component info
Next
End Sub
Here's the code in vb.net ( for apprentice)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Create a new instance of Apprentice.
Dim oApprentice As New ApprenticeServerComponent
' Open a document.
Dim oDoc As ApprenticeServerDocument
oDoc = oApprentice.Open("D:\U.......\Front Loader.iam") '
Dim oBOM As BOM
oBOM = oApprentice.Document.ComponentDefinition.bom
' or I tried also:
'
oBOM = odoc.ComponentDefinition.bom
' oBOM.StructuredViewEnabled = True 'cannot use this with apprentice
' oBOM.StructuredViewFirstLevelOnly = True 'cannot use this with apprentice
Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.Item("Structured")
Dim oRow As BOMRow
Dim i As Long
For i = 1 To oBOMView.BOMRows.Count
oRow = oBOMView.BOMRows.Item(i)
Dim oCompDef As ComponentDefinition
Dim oPropSet As PropertySet
Try
oCompDef = oRow.ComponentDefinitions.Item(1)
oPropSet = oCompDef.Document.PropertySets.Item("Design Tracking Properties")
Debug.Print("-: " & oRow.ItemNumber & " Quantity:" & oRow.ItemQuantity & "Part: " & oPropSet.Item("Part Number").Value & " Desc: " & oPropSet.Item("Description").Value)
Catch ex As Exception
End Try
Next
End Sub