Calculate Mass For Selected Bodies

Graphically select bodies and run the script to calculate the total mass for selected bodies.

Transparent


clr.AddReference("Ans.UI.Toolkit")
clr.AddReference("Ans.UI.Toolkit.Base")
from Ansys.UI.Toolkit import *

MassTotal = 0
SelectedBodies = ExtAPI.SelectionManager.CurrentSelection
WrapperBodies = SelectedBodies.Entities
MechanicalBodies = list()

for WrappedBody in WrapperBodies: MechanicalBodies.append(Model.Geometry.GetBody(WrappedBody))
for Body in MechanicalBodies: MassTotal += Body.Mass.Value

MessageBox.Show("Total Mass Of Selected Bodies = " + str(MassTotal) +".")