Goal: Calculate the sum of the volume, area, and length of the scoped entities.
Code:
clr.AddReference("Ans.UI.Toolkit")
from Ansys.UI.Toolkit import *
sel = ExtAPI.SelectionManager.CurrentSelection.Ids
sum = 0
for geoid in sel:
geoEntity = ExtAPI.DataModel.GeoData.GeoEntityById(geoid)
if geoEntity.Type == GeoCellTypeEnum.GeoBody:
sum += geoEntity.Volume
type = "volume"
unit = ExtAPI.DataModel.Project.Model.Geometry.LengthX.Unit + "^3"
if geoEntity.Type == GeoCellTypeEnum.GeoFace:
sum += geoEntity.Area
type = "area"
unit = ExtAPI.DataModel.Project.Model.Geometry.LengthX.Unit + "^2"
if geoEntity.Type == GeoCellTypeEnum.GeoEdge:
sum += geoEntity.Length
type = "length"
unit = ExtAPI.DataModel.Project.Model.Geometry.LengthX.Unit
MessageBox.Show("Total selected "+type+" is: "+str(sum)+" "+unit)