Hi, Try this rule from the assembly.
This rule will look at the BOM parts only, take the quantity and multiply it by the volume and with this value it will create a property called "TotalVolume" in each part. It will also create another custom property called "TotalMass".
I hope this is what you are looking for or that at least it will help you to achieve it. regards
Dim doc As AssemblyDocument = ThisDoc.Document
Dim oAssyDef As AssemblyComponentDefinition = doc.ComponentDefinition
Dim oBOM As BOM = oAssyDef.BOM
oBOM.PartsOnlyViewEnabled = True
Dim oBOMView As BOMView = oBOM.BOMViews.Item(3)'BOM parts only
Dim oBOMRow As BOMRow
For Each oBOMRow In oBOMView.BOMRows
Dim Qty As Double = oBOMRow.TotalQuantity
Dim rDoc As Document = oBOMRow.ComponentDefinitions.Item(1).Document
Dim oVoltotal As Double = rDoc.ComponentDefinition.MassProperties.Volume * Qty
Dim oMassTotal As Double = rDoc.ComponentDefinition.MassProperties.Mass * Qty
Try
rDoc.PropertySets.Item("Inventor User Defined Properties").Item("TotalVolume").Value = Round(oVoltotal, 0) & " cm^3"
Catch
rDoc.PropertySets.Item("Inventor User Defined Properties").Add(Round(oVoltotal,0) & " cm^3", "TotalVolume")
End Try
Try
rDoc.PropertySets.Item("Inventor User Defined Properties").Item("TotalMass").Value = Round(oMassTotal,3) & " Kg"
Catch
rDoc.PropertySets.Item("Inventor User Defined Properties").Add(Round(oMassTotal,3) & " Kg", "TotalMass")
End Try
Next
Please accept as solution and give likes if applicable.
I am attaching my Upwork profile for specific queries.
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn