Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bug in Apprentice Server when quering BOM?

0 REPLIES 0
Reply
Message 1 of 1
info
276 Views, 0 Replies

Bug in Apprentice Server when quering BOM?

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

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report