How can I get the centroid of multiple edges,

kkman
kkman Member Posts: 7
Name Dropper First Comment
**

I have two questions below,

  1. Is there a way to get edge loops similar to the “extend to limits” function? I need to use the counts in edge loops for further development.

  2. How can I get the centroid of multiple edges, similar to the edges summary in selection information?
    I could use ExtAPI.UserInterface.GetPane to get this information, but it might be slower than accessing it directly with GeoData.

Answers

  • Erik Kostson
    Erik Kostson Member, Moderator, Employee Posts: 276
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited November 1

    Hi

    1. To use the extend limit and adjacent tools see this:

    https://discuss.ansys.com/discussion/comment/2460#Comment_2460?utm_source=community-search&utm_medium=organic-search&utm_term=toolbar

    1. ExtAPI.UserInterface.GetPane :

    I do not think that works for Selection Information (only way I know is to use jscript and export info to text file). There is a post here in the forum on this. (https://discuss.ansys.com/discussion/3394/how-do-i-fetch-selection-information-data-in-mechanical)

    To do it manually get all centroids and calculate the average to get the overall centroid of all perhaps

    Hope this helps

  • kkman
    kkman Member Posts: 7
    Name Dropper First Comment
    **

    Hi Erik,

    Thanks for your quick response:)
    As I know, the DoGraphicsAdjacentSelectRecursive(ExtAPI) must interact with the GUI, and its performance is lower than running in the background.
    So is there other alternative that can replace DoGraphicsAdjacentSelectRecursive(ExtAPI)?
    If my understanding above is incorrect, please feel free to correct me.

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

    See the Bolt Tools Add on in Mechanical. Load it and use the console to see the app directory.

    In the app directory there is a file: GeoConnectivityHelper.py

    This module will help get connected edges and faces so you can work with them as a 'zone' concept (multiple connected entities).

    One of the methods on the zone classes is GetCentroid(), which will calculate the centroid of the zone (code is all there). No need for the UI to be open or to read info from UI controls.

  • kkman
    kkman Member Posts: 7
    Name Dropper First Comment
    **

    Hi Mike,

    Thank you for your suggestion. I took some time to understand the content in GeoConnectivityHelper.py and executed the code below. However, it still doesn’t seem to retrieve the correct centroid of these three edges.

    I wonder if my code might be incorrect or used in the wrong way. Could you please give me some suggestions if there’s anything wrong? Thanks!