How do I select bodies by centroid in DesignModeler scripting?

Landon Mitchell Kanner
Landon Mitchell Kanner Member, Employee, GitHub-issue-creator Posts: 316
50 Answers 100 Comments Second Anniversary 25 Likes
✭✭✭✭

I want to select bodies by centroid via scripting in DesignModeler

Tagged:

Answers

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee, GitHub-issue-creator Posts: 316
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited December 2023
    centroid = [0.25, 1.5, 4.5]
    tolerance = 0.001
    bodies_to_select = []
    for body in ExtAPI.DataModel.GeoData.Bodies:
        if abs(body.Centroid[0] - centroid[0]) < tolerance:
            if abs(body.Centroid[1] - centroid[1]) < tolerance:
                if abs(body.Centroid[2] - centroid[2]) < tolerance:
                    bodies_to_select.append(body)
    
    ExtAPI.SelectionManager.ClearSelection()
    ExtAPI.SelectionManager.AddSelection(bodies_to_select)