Message 1 of 4
How to iterate through each Part in a Parts Only BOMview?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Basically im making code that will iterate through each part in an assembly get the quantity of the part and then open the part to get a dxf and and area, then take this info and fill out an excel sheet. I've got the parts only bom view set up to give me quantity of each item using a counter. Now I want a for loop that will be something like:
For each Item in oPartsOnlyBOMView
'open item and make dxf etc. here
Next
But I cant get the syntax right to iterate through each item in the parts only bom view. Can someone please help. This is where im at and I'm using VB:
Dim oBOM As BOM
Dim oDoc As Document
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
Set oBOM = oAsmDoc.ComponentDefinition.BOM
' Make sure that the parts only view is enabled.
oBOM.PartsOnlyViewEnabled = True
' Set a reference to the "Parts Only" BOMView
Dim oPartsOnlyBOMView As BOMView
Set oPartsOnlyBOMView = oBOM.BOMViews.Item("Parts Only")
For Each oDoc In oPartsOnlyBOMView
openDoc = ThisApplication.Documents.Open(oDoc.FullDocumentName, True)
ThisApplication.ActiveDocument.Close
Next
Jake Egley
Inventor 2022
Inventor 2022