Read Model Normal to face orientation

Is there any way to read the X,Y,Z orientation based on a certain normal-to-face (F8) state of a model?

Which would give a result for example: XDirection as (1,0,0) and NormalDirection as (0,0,1)

Currently I am hardcoding the coordinates for XDirection and Normal Direction, but reading these two direction by the currentnormal state would be helpful.

The ModelingView object has a .GetAxis method that looks like it would be useful for your process. According to the API documentation:
"These are the components of the 3x3 matrix which is the rotation of absolute space which results in view space."

Thanks for the idea. I found that in the documentation. Can you give me an example of the syntax? Getting squiggly line under View.GetAxis

View.GetAxis(XYZAxis.XAxis)

Regards,
MFJ

The code below rotates the current modeling view 90 degrees about the view's Z axis.

Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module115
Sub Main(ByVal args() As String)

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow

lw.Open()

Dim myView As ModelingView = theSession.Parts.Work.ModelingViews.WorkView
Dim rotAxis As Vector3d = myView.GetAxis(XYZAxis.ZAxis)
Dim rotationAngleDegrees As Double = 90
myView.Concatenate(myView.AbsoluteOrigin, rotAxis, (Math.PI / 180) * rotationAngleDegrees)

End Sub
End Module

Great. This works perfectly as expected!

Regards,
MFJ

One more question,

While I am trying to read the normal axis (XYZAxis.ZAxis) I am getting correct coordinates like (0, 0, 1)

But While I am reading the Horizontal axis (XYZAxis.XAxis) I am getting the right reading for XAxis, but the vertical axis have wird value, instead of just 0. Something like this- (6.234542E-17, 0 , 1)

Do you know why? Or the slution?

Regards,
MFJ

The value 6.23E-17 is an extremely small number (almost zero); due to how computers store floating point numbers, these small 'rounding' errors are common. If you'd like to eliminate small values near zero, I'd suggest comparing the results to a desired 'tolerance' value. Something like below (pseudocode)

Const toleranceValue as double = .0001
if abs(x) < toleranceValue then
x = 0
end if

Edit for more info:
The vec3 .Unitize method might also be helpful here. You pass in the vector and a tolerance and it will return the magnitude and the unit vector. I've not used it recently, but it might round off those small values for you.

Regardless of zeroing it out it served my purpose because it is really close to zero. Thanks a lot. This will definitely help.

Regards,
MFJ

Hi all,
In order to get the material (not sheet metal) thickness, I'm trying to get the edge/face which is parallel to the normal vector, and then measure their length.

I found that DatumPlane Class has the property "normal", but aside from DatumPlane.Normal how can I read the normal vector?

After I get the normal vector, I assume that I have to compare every feature with normal vector through the class NXOpen.Features.Parallel , am I right?
If so, the problem is, there is no GetFace or GetEdge in feature class...

I tried to convert the design like body and extrusion into sheet metal, and get the thickness. But how can I convert them back to their original design, if I don't want to delete the feature by mouse?

Thanks for a reply in advance!

Best regards,
Ray

The NXOpen API has a "CheckMinimumWallThicknessBuilder" that sounds like it might be useful to you. I've not used it and could find no examples on the Siemens support site. It may require a special license. In interactive NX, use the command finder to search for "check wall thickness" and try to use the command. If it completes successfully, either it doesn't require a special license or you have access to it.

If you need the normal of a face, one way to get it is to use "AskFaceProps". Some discussion can be found in this thread:
https://nxjournaling.com/content/create-points-faces-and-get-coordinates...