How can I get the centroid of a surface in Spaceclaim?

Erik Kostson
Erik Kostson Member, Employee Posts: 101
First Answer Name Dropper First Anniversary Ansys Employee
edited September 2023 in General Language Questions

How can I get the centroid of a surface and show it in a dialogue box?

Best Answer

  • Erik Kostson
    Erik Kostson Member, Employee Posts: 101
    First Answer Name Dropper First Anniversary Ansys Employee
    edited September 2023 Answer ✓

    Below is a script that does that

    import clr
    clr.AddReference('System.Windows.Forms')
    
    from System.Windows.Forms import Application, Button, Form, TextBox, Label, MessageBox
    
    selected_items = Selection.GetActive().Items
    for selected_item in selected_items:
        if isinstance(selected_item, DesignFace):
            sel_i = Selection.Create(selected_item)
            t=MeasureHelper.GetCentroid(sel_i)
            MessageBox.Show(str(t))