How can I get the centroid of multiple geo entities in Mechanical?
How can I get the centroid of multiple geo entities via scripting in Mechanical
Answers
-
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\BoltToolsOpen this file:
GeoConnectivityHelper.pyReview code for the class/Method:
FaceConnectivityMap.Zone.GetControid()Example usage in Mechanical:
Import the code for use:
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)Use the code: Have some faces selected prior to using it.
Zone=GeoConnectivityHelper.FaceConnectivityMap.Zone()
Zone.Faces = list(ExtAPI.SelectionManager.CurrentSelection.Entities)
print Zone.GetCentroid()1