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

Erik Kostson
Erik Kostson Member, Employee Posts: 233
50 Answers 100 Comments Second Anniversary 25 Likes
✭✭✭✭
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: 233
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    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))