Getting Face Normal

I would like to get the normal of a face as a line or two point3d coordinates.

The purpose of this is to calculate the angle between two normals. I need help just getting the line or point3d coordinates, the rest I know how to do.

I suppose I would need to use MeshFaceNormalList.Item (but I have no idea how)

Thanks

You don’t need anything other than the two normals to calculate the angle. If you call the static method

var angle_in_radians = Rhino.Geometry.VectorAngle(normal1, normal2);

… then you have it. See https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Vector3d_VectorAngle.htm

If you need to calculate the angle as projected to a certain plane, then that’s a bit different, but you didn’t say that, so…

// Rolf

1 Like

You can access mesh face normals through Mesh.FaceNormals and get/set etc. from there:

https://developer.rhino3d.com/5/api/RhinoCommonWin/html/T_Rhino_Geometry_Collections_MeshFaceNormalList.htm

Edit: Apologies, you had already found this. Here’s an example:

180720_MeshFaceNormalsCenters_00.gh (365.3 KB)

1 Like

Hello and thanks for the replies.

When I use this with Python I get the Normals Count and it works.

normalsCount = mesh.FaceNormals.Count
print normalsCount

But when I use:
normalForFaceID1 = mesh.FaceNormals.Item(1)

I get error:
Message: indexer# is not callable

Any idea what I am doing wrong here?

Thanks

Yes, using Item takes square brackets. The reason I just went and assigned the normals to a list in line five, is that this will be quite a bit more performant. Using the Item call seems to be expensive for some reason. Anyhow, probably not a major concern.

1 Like

Thanks. All works now.

Good to know that I should assign all the normals to a variable and then directly take them from it.

Thanks a lot Anders and Rolf for helping me out on this.

1 Like