Why does the same face object have two different normals?

Why does the same face object have two different normals?

kristian_oa
Enthusiast Enthusiast
136 Views
2 Replies
Message 1 of 3

Why does the same face object have two different normals?

kristian_oa
Enthusiast
Enthusiast

I am encountering a strange situation where retrieving a face through the command manager's picker and directly through the Inventor API (by iterating the object's faces) returns different normals for the same face.

 

I know the two faces are identical as their InternalName property is identical between the two along with every other property. However, when parsing their data to find their normal, depending on how the face was retrieved (through the Pick command or through pure API calls), the normal produced seems to vary.

 

I have narrowed this down to the fact that the face being selected is within a part from a sub-assembly, whose XYZ orientation is different to that of its parent's (the sub-assembly's). The sub-assembly's XYZ orientation does match that of the main assembly.
It seems the picker transforms the picked face's normal to that of the main assembly's XYZ axis, but accessing the face directly uses its part's XYZ axis.

 

How is it that if the face being picked is identical to that of the face accessed by the API produces two different normals when they are both passed through the same "GetFaceNormal" function? Please see below for my implementation of this function.

/// <summary>
/// Returns a Unit Vector representing the normal of the given face.
/// </summary>
/// <param name="face">The face to retrieve the normal from.</param>
/// <returns>The Unit Vector representing the face's normal.</returns>
public static UnitVector GetFaceNormal(Face face)
{
    UnitVector normal = null;

    if (face != null)
    {
        Face f = (Face)face;

        double[] normalPoints = [0, 0, 0];
        double[] point = [f.PointOnFace.X, f.PointOnFace.Y, f.PointOnFace.Z];
        f.Evaluator.GetNormalAtPoint(ref point, ref normalPoints);
        normal = Globals.InventorApp.TransientGeometry.CreateUnitVector(normalPoints[0], normalPoints[1], normalPoints[2]);
    }
    return normal;
}

 

 Is there something I am not understanding correctly or perhaps am overlooking?

0 Likes
Accepted solutions (1)
137 Views
2 Replies
Replies (2)
Message 2 of 3

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @kristian_oa 

When you pick the face, in assembly context, what youre actually picking is the FaceProxy - which is the face representation in the assembly context. FaceProxy is derived from Face which allows it to be declared as being of type Face. I assume when you get it by code you're actually getting it from the PartComponentDefinition?

For the picked face - try declaring it as FaceProxy and get the normal from FaceProxy.NativeObject. That should give you the same normal as the face accessed through the PartComponentDefinition. 🙂

Message 3 of 3

kristian_oa
Enthusiast
Enthusiast

Thank you. This was the precisely what I was missing.

And yes, when retrieving my face through code, it was via the PartComponentDefinition.

0 Likes