08-31-2018
07:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
08-31-2018
07:44 AM
This should do what you want.
Sub Main()
Dim oDoc as AssemblyDocument = ThisApplication.ActiveDocument
Dim oBom as BOM = oDoc.ComponentDefinition.BOM
oBOM.PartsOnlyViewEnabled = True
Dim oBOMView as BOMView = oBOM.BOMViews.Item("Parts Only")
'assigned in loop
Dim oRow as BOMRow
Dim oCompDef as ComponentDefinition
Dim oPropSet as PropertySet
Dim pQty as Inventor.Property
Dim oBOMDoc as Document
For Each oRow In oBOMView.BOMRows 'i=1 To oBOMView.BOMRows.Count
'oRow = oBOMView.BOMRows.Item(i)
oCompDef = oRow.ComponentDefinitions.Item("1")
oBOMDoc = oCompDef.Document
oPropSet = oBOMDoc.PropertySets.Item("Inventor User Defined Properties")
Try
pQty = oPropSet.Item("Assy Qty")
Catch
oPropSet.Add("Custom", "Assy Qty")
pQty = oPropSet.Item("Assy Qty")
End Try
pQty.Value = oRow.TotalQuantity
Next
End Sub