Cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting tangent faces

Gears Phenom Gears Phenom
Gears Phenom

NX 9

 

I have a user, that is naming faces, ie he sets the selection filter to "face", selects them, right click over the face(s), Properties, then assignes the name.  Some parts have numerous faces, but he only wants the internal faces.  When in various commands, you can set the selection filters to "tangent faces", but not when outside a command like this.

 

Any thoughts on how he can make the selection of these faces easier?

-Dave
NX 11 | Teamcenter 11 | Windows 8.1
6 REPLIES

Re: Selecting tangent faces

Siemens Phenom Siemens Phenom
Siemens Phenom

What is the purpose once the name is assigned? Synchronous Modeling has a "Group Face" feature that lets you select tangent faces.

 

What about this?

Use the Unsew command to unsew the interior faces as a single feature.  Then hide the original solid body, rectangle select the interior unsewn faces, assign the name attribute and then delete the unsew feature.

Regards, Ben

Re: Selecting tangent faces

Legend
Legend

This can be done with a journal as follows.

 

1. Select one of the faces of interest.

2. Get the edges of this face

3. For each edge get the adjacent face and for a point on the edge if both u and v  tangent vector are equal ( in direction) then the adjacent face is tangent.  Continue this until we reach non-tangent faces.

4. I would higlight these selected faces to ensure the user that the selection is correct.  If so then apply the provided name to all the faces.

 

Frank Swinkels

Re: Selecting tangent faces

Below is a journal that goes two levels from the seed face.  I have written it to be readable rather then efficient code so it should be relatively simple to extend it to further levels. Also I realized face normals is simpler.

 

Option Strict Off
Imports System
Imports System.Collections
Imports NXOpen
Imports NXOpen.Annotations
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.Utilities

Module NamingTangentFaces
    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 response As Selection.Response = Selection.Response.Cancel
        Dim seedface As Face = Nothing
        response = select_the_seedface(seedface)
        If response = Selection.Response.Cancel Or response = Selection.Response.Back Then
            GoTo end1
        End If
        
        Dim aposition(2) As Double
        Dim junk3(2) As Double
        Dim junk2(1) As Double
        Dim junk1 As Double = Nothing
        Dim parm1(1) As Double
        Dim parm2(1) As Double
        Dim n1(2) As Double
        Dim n2(2) As Double
        Dim isparallel As Integer = Nothing
        Dim firstleveltangentfaces As ArrayList = New ArrayList
        Dim secondleveltangentfaces As ArrayList = New ArrayList
        Dim theedges() As Edge = seedface.GetEdges
        Dim theedgefaces(1) As Face
        Dim thesecondlevelfaces(1) As Face
        For Each e1 As Edge In theedges
            theedgefaces = e1.GetFaces
            For Each f1 As Face In theedgefaces
                If f1.Tag <> seedface.Tag Then
                 ' check a point on the common edge for tangancy
                    ufs.Modl.AskCurveProps(e1.Tag, 0.5, aposition, junk3, junk3, junk3, junk1, junk1)
                    ufs.Modl.AskFaceParm(seedface.Tag, aposition, parm1, aposition)
                    ufs.Modl.AskFaceParm(f1.Tag, aposition, parm2, aposition)
                    ufs.Modl.AskFaceProps(seedface.Tag, parm1, aposition, junk3, junk3, junk3, junk3, n1, junk2)
                    ufs.Modl.AskFaceProps(f1.Tag, parm2, aposition, junk3, junk3, junk3, junk3, n2, junk2)
                    ufs.Vec3.IsParallel(n1, n2, 0.01, isparallel)
                    If isparallel = 1 Then
                        ' add f1 to 1st level tangent faces
                        firstleveltangentfaces.Add(f1)
                    End If
                End If
            Next
        Next
        ' now do a second level
        For Each f1 As Face In firstleveltangentfaces
            Dim thefirstleveledges() As Edge = f1.GetEdges
            For Each e2 As Edge In thefirstleveledges
                thesecondlevelfaces = e2.GetFaces
                For Each f2 As Face In thesecondlevelfaces
                    If f2.Tag <> f1.Tag Then

                        ' check a point on the common edge for tangancy
                        ufs.Modl.AskCurveProps(e2.Tag, 0.5, aposition, junk3, junk3, junk3, junk1, junk1)
                        ufs.Modl.AskFaceParm(f1.Tag, aposition, parm1, aposition)
                        ufs.Modl.AskFaceParm(f2.Tag, aposition, parm2, aposition)
                        ufs.Modl.AskFaceProps(f1.Tag, parm1, aposition, junk3, junk3, junk3, junk3, n1, junk2)
                        ufs.Modl.AskFaceProps(f2.Tag, parm2, aposition, junk3, junk3, junk3, junk3, n2, junk2)
                        ufs.Vec3.IsParallel(n1, n2, 0.01, isparallel)
                        If isparallel = 1 Then
                            ' add f1 to 1st level tangent faces
                            secondleveltangentfaces.Add(f2)
                        End If
                    End If
                Next
            Next

        Next
        Dim facename As String = "TESTNAME"
        seedface.SetName(facename)
        For Each f1 As Face In firstleveltangentfaces
            f1.SetName(facename)
        Next
        For Each f1 As Face In secondleveltangentfaces
            f1.SetName(facename)
        Next
end1:
    End Sub
    Function select_the_seedface(ByRef seedface As Face) As Selection.Response
        Dim message As String = "Select seed face"
        Dim selectionMask_array(0) As Selection.MaskTriple
        With selectionMask_array(0)
            .Type = UFConstants.UF_face_type
            .Subtype = 0
            .SolidBodySubtype = 0
        End With
        Dim cursor As Point3d = Nothing
        Dim resp As Selection.Response = _
        ui.SelectionManager.SelectTaggedObject("Face Selection", message, _
            Selection.SelectionScope.AnyInAssembly, _
            Selection.SelectionAction.ClearAndEnableSpecific, _
            False, False, selectionMask_array, seedface, cursor)
        If resp = Selection.Response.ObjectSelected Or _
           resp = Selection.Response.ObjectSelectedByName Then
            Return Selection.Response.Ok
        ElseIf resp = Selection.Response.Back Then
            Return Selection.Response.Back
        Else
            Return Selection.Response.Cancel
        End If
    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

 

Re: Selecting tangent faces

Gears Phenom Gears Phenom
Gears Phenom

@BenBroad  After it's named, an parasolid is exported out, and used in Star CCM+ for CFD.  The name remains assigned, and makes things easier once in the CFD world.

-Dave
NX 11 | Teamcenter 11 | Windows 8.1

Re: Selecting tangent faces

Siemens Phenom Siemens Phenom
Siemens Phenom
I originally thought what if you used Edit Object Display to change the colors of the faces using the tangent rule, and then use the color filter to select the faces... however, EOD does not utilize the face rule (ER 7310533). I also found ER 2212099 - Enable face rule to be used before selecting commands. If implemented this would work in your favor. I need to learn how to write journals - @FrankSwinks put my unsew solution to shame Smiley Happy

Regards, Ben

Re: Selecting tangent faces

Gears Phenom Gears Phenom
Gears Phenom

Let me know when that "Journals for Dummies" class is, I want to go.

-Dave
NX 11 | Teamcenter 11 | Windows 8.1