Goal: Calculate the sum of the volume, area, and length of scoped entities.
Code:
sum = 0
for geoid in ExtAPI.SelectionManager.CurrentSelection.Ids :
geoEntity = DataModel.GeoData.GeoEntityById(geoid)
if geoEntity.Type == GeoCellTypeEnum.GeoBody:
sum += geoEntity.Volume
type = "volume"
if geoEntity.Type == GeoCellTypeEnum.GeoFace:
sum += geoEntity.Area
type = "area"
if geoEntity.Type == GeoCellTypeEnum.GeoEdge:
sum += geoEntity.Length
type = "length"
# values are reported in the CAD unit system so get that
unit = Model.Geometry.LengthUnit
print("Total selected "+ type + " is: " + str(sum) + " "+ str(unit))