Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

NXOpen Angle measurement

Status
Not open for further replies.

intonate

Aerospace
Joined
Oct 9, 2014
Messages
4
Location
US
I am writing a macro to re-link wave linked faces, and to ensure the orientations align I am trying to measure the angle between the existing face and the new face.
I am getting an error on this line of code:

Code:
 MeasureAngle ang = workPart.MeasureManager.NewAngle((Unit)workPart.UnitCollection.FindObject("Degrees"), oldface,MeasureManager.EndpointType.StartPoint, face1, MeasureManager.EndpointType.EndPoint, false);

the error says:
NXOpen.NXException: Third parameter is invalid at NXOpen.MeasureManager.NewAngle(Unit units, DisplayableObject object1, EndpointType qualifier1, DisplayableObject object2, EndpointType qualifier2, Boolean minorAngle)

but I have tried all three options for the MeasureManager.EndpointType (StartPoint, None, and EndPoint). The documentation says that the qualifiers are only used for lines and edges though, so I dont' know why they affect anything when measuring two surfaces.

Any tips, or examples?
 
I created a new part file with 2 datum planes and wrote a quick journal to measure the angle between them. It seems to work correctly no matter the EndpointType option that is used. Code below is VB, not that it should matter...

Code:
Option Strict Off
Imports System
Imports NXOpen

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work

        Dim datumPlane1 As DatumPlane = CType(workPart.Datums.FindObject("DATUM_PLANE(1)"), DatumPlane)
        Dim datumPlane2 As DatumPlane = CType(workPart.Datums.FindObject("DATUM_PLANE(2)"), DatumPlane)

        Dim ang As MeasureAngle = workPart.MeasureManager.NewAngle(workPart.UnitCollection.FindObject("Degrees"), datumPlane1, MeasureManager.EndpointType.None, datumPlane2, MeasureManager.EndpointType.None, False)
        MsgBox(ang.Value)

    End Sub

End Module

www.nxjournaling.com
 
do you think it could be something wrong with my surfaces then?
I am getting the "oldface" like this (TopSkinSurface is a broken wave linked face feature):

Code:
   NXOpen.Features.ExtractFace topSurfaceFeature = (NXOpen.Features.ExtractFace)Utilities.GetNamedFeature(workPart, "TopSkinSurface");
workPart.Features.SetEditWithRollbackFeature(topSurfaceFeature);
theSession.UpdateManager.InterpartDelay = true;
topSurfaceFeature.MakeCurrentFeature();

Face oldface = topSurfaceFeature.GetFaces().First();

and my "face1" is from a user selection in the displayPart (using a block UI styler dialog):
Code:
Face face1 = (Face)face_select01.GetSelectedObjects().First();

does the measureManager require that both objects be in the workPart?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top