Ansys Learning Forum Forums Discuss Simulation Preprocessing Spaceclaim API – Select faces at given coordinates Reply To: Spaceclaim API – Select faces at given coordinates

PPosabella
Subscriber

Thank you for your answer!

 

However, I am working on more complex structures than the one I described above. I managed to work on the normal vectors of each face, here I attach the code I developed (it may require adjustments, but for now it's doing its job)

 

numFaces = len(GetRootPart().Bodies[0].Faces) # get number of total faces
selectedFaces = [] # initialise vector to include required faces

for i in range(0, numFaces - 1): # select faces knowing their normal vector
    if str((GetRootPart().Bodies[0].Faces[i].GetFaceNormal(0,0)))  == 'Direction: (0, 0, -1)': # choose normal vector. Still don't know how GetFaceNormal(0,0) is affecting the code
            selectedFaces.append(GetRootPart().Bodies[0].Faces[i]) # append face

print(selectedFaces)

# Define Named Selection
primarySelection = FaceSelection.Create(selectedFaces)
secondarySelection = Selection.Empty()
result = NamedSelection.Create(primarySelection, secondarySelection)
# Rename Named Selection
result = NamedSelection.Rename("Group1", "myNamedSelection")