Compute surface normal of face
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.
Regards,
Rahul
Comments
-
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 MeshTopoList.append(mesh.GetDesignMeshTopology(face)) if len(MeshTopoList) > 0: Selection.Create(MeshTopoList).CreateAGroup("PositiveZ_Fins")
2 -
Hi Rajesh,
Thank you very much, this works perfect!
Regards,
Rahul
0