How can I get the centroid of multiple geo entities in Mechanical?

Mike.Thompson
Mike.Thompson Member, Employee Posts: 339
25 Answers 100 Comments 25 Likes First Anniversary
✭✭✭✭

How can I get the centroid of multiple geo entities via scripting in Mechanical

Answers

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 339
    25 Answers 100 Comments 25 Likes First Anniversary
    ✭✭✭✭

    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:

    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()