Autodesk Inventor’s BoM environment is a really useful tool for understanding the composition of Assembly files, but the one thing it does not offer, is the total Mass of the assembly.
To remedy this, I have written some iLogic code to create a virtual component, the Mass of the Assembly is written to a custom iProperty called “Assembly Mass”, which can be displayed on the BoM.
The reason the Mass is written to a custom iProperty and not the Mass iProperty of the virtual component, is that if you assign Mass to a virtual component, the assembly Mass, and therefore centre of gravity etc. would all be inaccurate.
The code works well, the only thing left to do, is to add the custom iProperty to your BoM view, the animated GIF below shows this in action.
Here is the iLogic code:
'iLogic code by Clint Brown @ClintBrown3D 'Code originally posted at https://clintbrown.co.uk/display-assembly-mass-on-bom-with-ilogics 'Check that this is an Assembly oDoc = ThisDoc.ModelDocument If oDoc.DocumentType = kPartDocumentObject Then MessageBox.Show("This only works in Assemblies", "@ClintBrown3D") Return: End If 'Write Mass to the Virtual part (if it already exists) Try: iProperties.Value("Assembly Mass:1", "Custom", "Assembly Mass") = Round(iProperties.Mass,3) & " kg" Catch: End Try 'Check if the Virtual part exists Try: If Component.IsActive("Assembly Mass:1")= True Then: : End If Catch: End Try ' Create Virtual Component Dim oAssDef As AssemblyComponentDefinition oAssDef = oDoc.ComponentDefinition Dim oMatrix As Matrix oMatrix = ThisApplication.TransientGeometry.CreateMatrix NameOfVirtualPart = "Assembly Mass" Try: Dim oNewOcc As ComponentOccurrence oNewOcc = oAssDef.Occurrences.AddVirtual(NameOfVirtualPart, oMatrix) Dim oCVirtualCompDef As VirtualComponentDefinition oCVirtualCompDef = oNewOcc.Definition 'Write iProp Mass to Virtual Component iProperties.Value("Assembly Mass:1", "Custom", "Assembly Mass") = Round(iProperties.Mass,3) & " kg" Exit Sub : Catch : End Try MessageBox.Show("SUCCESS :)" & vbNewLine & vbNewLine &"Remember to add the Custom *Assembly Mass* iProperty to your BoM", "@ClintBrown3D")
This version of the code was briefly tested with Inventor 2020.2
Please note that I cannot offer any additional support, this blog post is offered as-is, and is aimed at the more advanced user.
As always, please test all iLogic code extensively on non-production files. Do not use any code in a production environment until YOU have thoroughly tested it and have verified that it works as expected. Always back up any data before running any experimental code. You are ultimately responsible for any iLogic code that you run, so make sure you test it thoroughly!
This site takes absolutely no responsibility for how you use this code in production (see disclaimer).