How to find a face based on its (xyz) location and make it into a named selection by script in SCDM?
Erik Kostson
Member, Employee Posts: 200
✭✭✭✭
We want to search an area in 3D space (based on x,y,z coordinates and a tolerance that makes the 3D search space a volume), and find any face(s) (centroid(s)) of a part(s) within this search volume. Finally if a face is found make it into a named selection by script in SCDM.
Tagged:
0
Answers
-
import math def locfindface(xx,yy,zz,tol): bodies = GetRootPart().GetAllBodies() for b in bodies: faces = b.Faces for f in faces: faceSelection=FaceSelection.Empty() faceSelection = FaceSelection.Create(f) e=MeasureHelper.GetCentroid((faceSelection)) tolz=1 toly=1 tolx=1 tolz=math.copysign(tolx,e[2])*tol toly=math.copysign(tolx,e[1])*tol tolx=math.copysign(tolx,e[0])*tol if (xx-xx*tolx<=e[0]<=xx+xx*tolx) and (yy-yy*toly<=e[1]<=yy+yy*toly) and (zz-zz*tolz<=e[2]<=zz+zz*tolz): secondarySelection = Selection.Empty() ns = NamedSelection.Create(faceSelection,secondarySelection) locfindface(0.24, 0.0025, -0.031,0.08) # call the above function
6