How can we iterate over all named sel. in Spaceclaim trying to get the centroid of a Solid body
Erik Kostson
Member, Employee Posts: 233
✭✭✭✭
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?
Tagged:
0
Best 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
0
This discussion has been closed.