Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: chandra.shekar.g

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