How can I get the centroid of multiple geo entities via scripting in Mechanical
You can use some code from the "Bolt Tools" add on in Mechanical. (this will work starting at about 23.2 and is being written as of 24.2)
Go to this folder: C:\Program Files\ANSYS Inc\v\aisol\WBAddins\MechanicalExtensions\BoltTools
Open this file: GeoConnectivityHelper.py
Review code for the class/Method: FaceConnectivityMap.Zone.GetControid()
Example usage in Mechanical:
CodePath = r'C:\Program Files\ANSYS Inc\v242\aisol\WBAddins\MechanicalExtensions\BoltTools' import sys if not CodePath in sys.path: sys.path.append(CodePath) import GeoConnectivityHelper GeoConnectivityHelper.Initialize(ExtAPI, Ansys)
Zone=GeoConnectivityHelper.FaceConnectivityMap.Zone() Zone.Faces = list(ExtAPI.SelectionManager.CurrentSelection.Entities) print Zone.GetCentroid()