Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Are Edges Tangent? 1

Status
Not open for further replies.

PrasannaNX

Automotive
Aug 5, 2014
31
0
0
IN
I am using NX 7.5.3.

I have list of edges from a face (which also has a hole). I need to loop through all edges to find connected edges and whether the connected edges are tangent are not?

Can someone suggest a suitable function or method to find connected edges and to check whether two given edges are tangent or not?

Thanks,
Prasanna M
 
Replies continue below

Recommended for you

The easiest and quickest scheme would be to go any function which acts on Faces, such as 'Offset Face', set the 'Face Rule' to 'Tangent Faces', select one of the faces of interest and watch to see what other faces are also highlighted.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Here is a journal that goes part of the way for what I think you want. The journal ask you to select a face. The journal then gets all edges of that selected face. Then for each edge we get the adjacent faces and checking for a point on the edge I get the normal on both faces at this point. If the normals are equal then the adjacent faces are tangent at that point. To demonstrate that faces are found or not I highlight the tangent faces and the originally selected face.

Now it is possible that an adjoining face is only partially tangent and so the journal may or may not find the appropriate faces. Also the journal only does the first set of adjacent faces. It does not go any further.

Hope this help you get started if more needs to be done.

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.Utilities

Module AdjacentTangentFaces
    Dim s As Session = Session.GetSession()
    Dim ui As UI = ui.GetUI()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim wp As Part = s.Parts.Work()
    Sub Main()
        Dim response1 As Selection.Response = Selection.Response.Cancel
        Dim startFace As Face = Nothing
        Dim faceTangency As Boolean = False
        response1 = select_a_face("Select a face", startFace)
        ufs.Disp.SetHighlight(startFace.Tag, 1)
        Dim startfaceEdges() As Edge = startFace.GetEdges
        For Each e1 As Edge In startfaceEdges
            Dim adjfacestags(-1) As Tag
            ufs.Modl.AskEdgeFaces(e1.Tag, adjfacestags)
            If adjfacestags(0) <> startFace.Tag Then
                ' check if adjacent face is tangent
                faceTangency = askForFaceTangency(startFace, e1, adjfacestags(0))
                If faceTangency = True Then
                    ufs.Disp.SetHighlight(adjfacestags(0), 1)
                End If
            ElseIf adjfacestags(1) <> startFace.Tag Then
                faceTangency = askForFaceTangency(startFace, e1, adjfacestags(1))
                If faceTangency = True Then
                    ufs.Disp.SetHighlight(adjfacestags(1), 1)
                End If
            End If
        Next
    End Sub

    Function select_a_face(ByRef prompt As String, ByRef face1 As Face) As Selection.Response
        Dim mask(0) As Selection.MaskTriple
        With mask(0)
            .Type = UFConstants.UF_solid_type
            .Subtype = 0
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_FACE
        End With
        Dim cursor As Point3d = Nothing
        Dim response1 As Selection.Response = Selection.Response.Cancel
        select_a_face = Nothing
        response1 = ui.GetUI.SelectionManager.SelectTaggedObject(prompt, prompt, _
            Selection.SelectionScope.AnyInAssembly, _
            Selection.SelectionAction.ClearAndEnableSpecific, False, _
            False, mask, face1, cursor)
        If response1 = Selection.Response.ObjectSelected Or _
            response1 = Selection.Response.ObjectSelectedByName Then
            Return Selection.Response.Ok
        ElseIf response1 = Selection.Response.Back Then
            Return Selection.Response.Back
        Else
            Return Selection.Response.Cancel
        End If
    End Function
    Function askForFaceTangency(ByVal startface As Face, ByVal testedge As Edge, _
                                 ByRef nextFacetag As Tag) As Boolean
        Dim istrue As Boolean = False
        Dim parm1(1) As Double
        Dim pointdbl(2) As Double
        Dim junk3(2) As Double
        Dim junk2(1) As Double
        Dim junk1 As Double = Nothing
        Dim normal1(2) As Double
        Dim normal2(2) As Double

        ufs.Modl.AskCurveProps(testedge.Tag, 0.5, pointdbl, junk3, junk3, junk3, junk1, junk1)
        ufs.Modl.AskFaceParm(startface.Tag, pointdbl, parm1, pointdbl)
        ufs.Modl.AskFaceProps(startface.Tag, parm1, pointdbl, junk3, junk3, junk3, junk3, normal1, junk2)
        ufs.Modl.AskFaceParm(nextFacetag, pointdbl, parm1, pointdbl)
        ufs.Modl.AskFaceProps(nextFacetag, parm1, pointdbl, junk3, junk3, junk3, junk3, normal2, junk2)
        Dim tangency As Boolean
        Dim tol1 As Double = 0.01
        ufs.Vec3.IsEqual(normal1, normal2, tol1, tangency)

        Return tangency

    End Function
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function

End Module

Frank Swinkels
 
Status
Not open for further replies.
Back
Top