Compute surface normal of face

RK Member, Employee Posts: 11
Name Dropper First Comment
edited July 2023 in 3D Design

Hello all, 

I have a faceted body as shown below and I would like to capture the top faces, bottom faces and cylindrical faces separately and assign named selections using scripting. There are hundreds of such fins and to manually assign named selections is very tedious and also each fin has different dimensions, but they are all cylindrical in shape. 

I was looking to compute the surface normal of all faces, put the faces whose normal is facing +Z in one bin and assign a named selection, do the same for -Z and for the rest assign another named selection.

Anyone has a better idea on scripting this? If computing the surface normal is the best option, can you please let me know the script to compute the normal? 

Thank you for your help. 




  • Rajesh Meena
    Rajesh Meena Moderator, Employee Posts: 77
    First Anniversary Solution Developer Community of Practice Member Ansys Employee 5 Likes


    Here is the script you can use for the same.

    # Python Script, API Version = V23
    meshes = GetRootPart().Meshes
    z_vector = Vector.Create(0,0,1)
    MeshTopoList = []
    for mesh in meshes:
        for face in mesh.Shape.Faces:
            normal = face.Normal.UnitVector
            dot_product = Vector.Dot(z_vector,normal)
            if dot_product > 0.9: #+ve z
    if len(MeshTopoList) > 0:

  • RK
    RK Member, Employee Posts: 11
    Name Dropper First Comment

    Hi Rajesh,

    Thank you very much, this works perfect!