Ansys 2023r1
And how to get the location or area information of these geometrys.
def Geo_list(): geo_list=[] for geoid in ExtAPI.SelectionManager.CurrentSelection.Ids : geoEntity = DataModel.GeoData.GeoEntityById(geoid) geo_list.append(geoEntity) return geo_list
for geo in Geo_list(): Print(geo.Area)
all_named_selections = ExtAPI.DataModel.GetObjectsByType(Ansys.ACT.Automation.Mechanical.NamedSelection) for ns in all_named_selections: print "named selection: {}".format(ns.Name) entities = ns.Entities for entity in entities: print " entity: {}".format(entity.Id) print " area: {}".format(entity.Area) print " centroid: {}".format(entity.Centroid)
Note: Depending on the type of the entity that is in the named selection (body, face, edge, vertex, node, element, or element face), the last two lines of the above code may behave differently. This version was tested using a face Named Selection.
Hi @ZZ.tang , the code you shared will work on the active selection in Mechanical, not on a named selection. For it to work on a named selection, the principle will be the same: