How can we iterate over all named sel. in Spaceclaim trying to get the centroid of a Solid body

Erik Kostson
Erik Kostson Member, Employee Posts: 233
50 Answers 100 Comments Second Anniversary 25 Likes
✭✭✭✭
edited May 2 in 3D Design

Say we have many named selections (NS) /groups in Spaceclaim, consisting of Solid 3D bodies. How can we automatically get the centroid of all these bodies belonging to the different NS/groups?

Best Answer

  • Erik Kostson
    Erik Kostson Member, Employee Posts: 233
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    Answer ✓

    Below is a code that does that (loops and gets the centroind / cen ):

    groups = GetActiveWindow().ActiveWindow.Groups
    for ns in groups:
        nm=ns.GetName()
        print(nm)
        me=ns.Members
        for mem in me:
            if isinstance(mem, DesignBody): # only DesignBodies
                mp=mem.MassProperties.RawSubject
                cen=mp.Center # get centroid
                print(cen[1]) # print y coordinate
    
This discussion has been closed.