Find the normal of surface

Find the normal of surface

supriya_chaugule
Contributor Contributor
445 Views
2 Replies
Message 1 of 3

Find the normal of surface

supriya_chaugule
Contributor
Contributor

Hiii.....I am trying to get the normal of each face of this model

supriya_chaugule_0-1686744063990.png

public static UnitVector GetFaceNormal(Face inputFace,PartDocument doc)
{
Inventor.TransientGeometry tg = mApplication.TransientGeometry;

SurfaceEvaluator eval = inputFace.Evaluator;

// Get the center of the parametric range.
double[] center = new double[2];
center[0] = (eval.ParamRangeRect.MinPoint.X + eval.ParamRangeRect.MaxPoint.X) / 2;
center[1] = (eval.ParamRangeRect.MinPoint.Y + eval.ParamRangeRect.MaxPoint.Y) / 2;

bool status = eval.IsParamOnFace[ref center];

// Calculate the normal.
double[] normal = new double[3];
eval.GetNormal(center, normal);

// Create a unit vector to pass back the result.
UnitVector faceNormal = mApplication.TransientGeometry.CreateUnitVector(normal[0], normal[1], normal[2]);

return faceNormal;
}

 

But every time I got normal as (0,0,0) .Any suggestion on how can I get correct normal? 

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

WCrihfield
Mentor
Mentor
Accepted solution

Hi @supriya_chaugule.  I am not sure why you may be attempting to find the center point on each face, but I suspect that the center point of at least two of the faces on that part will not be a point 'on' the face, but over the big hole through the part.  Have you tried using the parameters from the Face.PointOnFace (a Point object) instead of the faces center?  Or maybe use the GetNormalAtPoint method, instead of the regular GetNormal method.  The GetNormalAtPoint method allows you to input the actual 3D Point X, Y,& Z coordinates to use.  It says that the point must be 'on' the surface though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

supriya_chaugule
Contributor
Contributor

Thank you @WCrihfield Its working with getNormLAtPoint method.

0 Likes