Scripting

Bobin John
Bobin John Member Posts: 8
First Comment
**
edited June 2023 in 3D Design

How do I search the faces of a body that is parallel to a certain plane in Scripting?

Answers

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 345
    25 Answers 100 Comments 25 Likes First Anniversary
    ✭✭✭✭

    This is an example for getting faces in line with the X direction. Replace this with whatever vector you like.

    def FaceIsXDirection(F, Tol=0.999):
        Dot = Vector.Dot(Direction.DirX.UnitVector, F.GetFaceNormal(0,0).UnitVector)
        return abs(Dot)>Tol
    
    XFaces=[]
    for B in GetRootPart().GetAllBodies():
        for F in B.Faces:
            if FaceIsXDirection(F):
                XFaces.append(F)
    
    Selection.Create(XFaces).SetActive()
    
  • Bobin John
    Bobin John Member Posts: 8
    First Comment
    **

    The above code works, which led me to another question - How would the code look if I need the faces that had a particular Y coordinate (say passing through Y=0.5)? This way I can select all faces parallel to a particular plane and also have a common coordinate in them.