Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Face Normals

Is there a way to track face normals and flip them through NXOpen. I cant seem to find any information on it. Want to be able to flip face normals to make sure a face blend always works. I could do this TRYing all options but I dont want to do a brute force method and sometimes it might work in the wrong orrientation. Thanks.

3 REPLIES
Solution
Solution
Accepted by topic author Dmaldo01
‎07-14-2017 02:51 PM

Re: Face Normals

The .AskFaceProps method will return the normal direction information at a user specified UV location. Interactive NX has a "reverse normal" command; there should be an API function equivalent, but I don't know the function name off the top of my head.

Re: Face Normals

Thanks. This does end up working. Copying this here for others to see if they had similar concerns. 

 

Dim pt(2) As Double
        Dim u1(2) As Double
        Dim v1(2) As Double
        Dim u2(2) As Double
        Dim v2(2) As Double
        Dim norm(2) As Double
        Dim radii(1) As Double
        Dim param(1) As Double
        theUfSession.Modl.AskFaceParm(facetag, cp , param, pt)
        theUfSession.Modl.AskFaceProps(facetag, param, pt, u1, v1, u2, v2, norm, radii)

 The interactive face normal was where i first started but I couldnt get this to output into a journal so not quite sure what command it. While looking for how to use AskFaceProps I also found another  way that would work which was using the associative line builder endoption.normal as well as 

 

 
workPart.Directions.CreateDirection(faceOfInterest, PointOnFace, NXOpen.Sense.Forward, NXOpen.SmartObject.UpdateOption.WithinModeling)

Re: Face Normals

[ Edited ]

At a given point, there are two common "normal" vectors that you might want to use.

 

(1) The "natural" normal, which is the cross product of the partial derivatives at the point, and

(2) The "outward" normal -- the one that points away from material, into air.

 

To understand the difference, it might be useful to read the material in the SNAP Reference Guide, specifically you might read about the Snap.NX.Face.Normal function and the Snap.NX.Face.Sense property.

 

I have incuded some of the text below, but the formatting is pretty messed up. The original SNAP doc is easier to read and includes code examples.

 

 

Normal Method (uv)

NamespacesSnap.NXFace ► Normal(array<Double>)

Evaluates the face normal at given (u,v) parameter values

 

Declaration Syntax

Public Function Normal (

        ParamArray uv As Double()

) As Vector

Dim instance As Face

Dim uv As Double()

Dim returnValue As Vector

 

returnValue = instance.Normal(uv)

 

Parameters

uv (array<Double>[]()[][])

The (u,v) parameter values -- not normalized to the range [0,1]

 

Return Value

Vector Face normal at the given (u,v) parameter values (a unit vector)

 

Remarks

This function returns the "natural" normal vector, which is parallel to the cross product of the partial derivatives. Typically, Normal(uv) is a unit vector parallel to Cross(DerivDu(uv), DerivDv(uv). However, sometimes one of the partial derivatives is zero. In this case the cross product will also be zero, and will provide no useful information. This function will return a correct surface normal vector even in these unpleasant cases.

The natural face normal directions for some common surface types are as follows:

  • Cylinder: Away from its centerline
  • Cone: Away from its centerline
  • Sphere: Away from its center

It is often useful to compute an "outward" normal on the surface of a solid object (i.e. a normal vector that points away from material, towards empty space). To do this, you compute a natural normal vector using this function, and then adjust its sense using the Face.Sense property.

 

 

Sense Property

NamespacesSnap.NXFace ► Sense

The sense of the outward face normal

 

Declaration Syntax

Public ReadOnly Property Sense As Sense

        Get

Dim instance As Face

Dim value As Sense

 

value = instance.Sense

 

Property Value

Sense

 

Remarks

This property helps you determine on which side of a face material lies.

To compute an outward normal, you first get the "natural" normal by calling the Face.Normal function, and then you multiply this by Face.Sense.

On a cylindrical face, the natural normal points away from the centerline. So, if a cylindrical face has Face.Sense = Sense.Positive, this means that the outward normal also points away from the centerline, so the face must be part of a boss. Similarly, if a cylindrical face has Face.Sense = Sense.Negative, it must be part of a hole.

 

 

山田
yamada