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: 

Export BOM using VB.net

3 REPLIES 3
Reply
Message 1 of 4
Raider_71
1527 Views, 3 Replies

Export BOM using VB.net

Hi guys,

 

I created a program to export the Assembly BOM to Excel. I am running into a some strange behaviour regarding Weldments and Inseparable  assemblies. Here is a snippet of my code:

'Create BOM Object

Dim oBom As Inventor.BOM

oBom = oAssyDoc.ComponentDefinition.BOM

oBom.StructuredViewEnabled = True

oBom.StructuredViewDelimiter = "."

oBom.StructuredViewFirstLevelOnly = False

 

'Create BOMView Object

Dim oBomView As Inventor.BOMView

oBomView = oBom.BOMViews.Item(2)

 

'Create Row Object and run For loop to export

Dim oRow As Inventor.BOMRow

 

For Each oRow In oBomView.BOMRows

 

'This is where I put my code to export and write the file.

 

Next

 

I run into the issue of the items inside a Weldmant assembly is not being exported. Yet I am able to create a structured multilevel partslist on my drawing showing all the items inside the Weldment.

 

Whats strange is that even if I change the Weldment assy’s BOM structure to Normal, it still does not make a difference.

Is there a way to get the items of a Weldment into my BOMRows object so that it will export?

 

Whats starnge is that if an assembly is set to “Inseparable” but is not a weldment then it exports the contents.

 

Any light on the subject would be appreciated!

3 REPLIES 3
Message 2 of 4

Could you please upload the simplest Inventor assembly along with the test code (not snippet) that can reproduce the problem.
Thanks,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 4

Hi I have found the issue.

 

Further down in my code I was checking if the ComponentDefinitions was of type Assembly. Not knowing that a weldment is not actually classed as an assembly in this case. I have added checking for that as well now and its working now thanks! Here is the code jyst for reference:

 

If oBOMRow.ComponentDefinitions.Item(1).Type = ObjectTypeEnum.kAssemblyComponentDefinitionObject Or oBOMRow.ComponentDefinitions.Item(1).Type = ObjectTypeEnum.kWeldmentComponentDefinitionObject Then
  If oBOMRow.ChildRows.Count > 0 Then
    For Each oRow As Inventor.BOMRow In oBOMRow.ChildRows

        subGetRowInfo(oRow)

    Next
 End If
End If

Message 4 of 4

My congratulations!


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report