Let's assume I have selected a set of bodies of interest and placed those in a Named Selection (e.g. "MySelection").
You can use the following snippet to:
'''Starting from a named selection containing only bodies "MySelection" ''' named_selection = DataModel.GetObjectsByName("MySelection")[0] selection_mass = 0 # Initiating total mass counter ''' Iterating over the body IDs in the named selection and summing the mass of each''' for bID in named_selection.Location.Ids: geobody = ExtAPI.DataModel.GeoData.GeoEntityById(bID) # Converting to tree body object to benefit from the available .Mass property treebody=ExtAPI.DataModel.Project.Model.Geometry.GetBody(geobody) selection_mass = selection_mass + treebody.Mass.Value '''treebody.Mass will report the mass units as well. You may check the consistency of units across your bodies before summing'''