I have been successful in retrieving the mass properties for the entire assembly, but what I really need is the mass properties for each of the components. My current code runs as follows:
Creates a pointer to IModelDoc2 and gets the active assembly document. Initializes a component array and bodies variable which points to IComponent2 and IBody2, respectively. Starts a for loop to iterate through each component. Gets the name and bounding box of each component using a member of IComponent2. Uses IGetMassProperties member of IModelDoc2 to get the mass properties of the assembly. Saves information in a .csv file and exits.
My code is able to run, but the the mass properties document I save returns the same values for all four components (the values for the entire assembly). I have tried using the GetBodies2 member of IComponent2 followed by IMassProperty->AddBodies, but I have not been successful in getting this to run. I have tried several other methods as well but to no avail. I am thinking I might have to suppress all of the components except the one I want the mass properties for, but I do not know how to implement this. I would really appreciate some help. Thanks.