Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NX Journal Selection Priority

Status
Not open for further replies.

TheWenger

Aerospace
Apr 25, 2013
16
I'm creating a journal using basic selection, and using this as a guide. I'm running into a sort of strange issue.

Using normal selection in NX, with no selection filters, the priority starts with components. I click on a body in an assembly, and the component is what's selected. But when I run the journal using the same selection technique from the tutorial, the selection priority starts with the solid body within the desired component. Now I may or may not have write access to that, and even if I did, I wouldn't want to dig into every component in the selection So is there a way of changing the selection priority within a journal to grab components as a whole and not trying to grab the child body?
 
Replies continue below

Recommended for you

The selection priority you have set will influence the selection in that journal. Also, the user can select a filter to refine the selection while that journal is running.

If you want to set the selection to automatically filter for components, you should use the version of the select object function that allows you to set up a "mask triple".
For a component the mask triple values are:

Code:
Dim selectionMask_array(0) As Selection.MaskTriple

With selectionMask_array(0)
  .Type = UFConstants.UF_component_type
  .Subtype = UFConstants.UF_all_subtype
  .SolidBodySubtype = 0
End With

www.nxjournaling.com
 
That works great, thanks. But what if I still want to be able to select solid bodies, if I'm in a part file for example. I tried adding another array item with UF_solid_type and tried it in both the 0 and 1 position and it always seemed to override the UF_component_type.
 
You can add more mask triples values to widen your selection filter. The following will allow the user to select a component or a solid body:

Code:
Dim selectionMask_array(1) As Selection.MaskTriple

With selectionMask_array(0)
	.Type = UFConstants.UF_component_type
	.Subtype = UFConstants.UF_component_subtype
        .SolidBodySubtype = 0
End With
With selectionMask_array(1)
	.Type = UFConstants.UF_solid_type
        .Subtype = 0
	.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
End With

However, when run in an assembly, selection priority will kick in and it is up to the user to make sure they are selecting a component instead of a body (or vice versa).

www.nxjournaling.com
 
Right, that's pretty much what I did. The default selection priority outside of the journal is components first. If I only use one mask, it gets components. If I add the solid mask it then prioritizes that, even though the default outside of the journal is component.

Is there a standard NX default that has to be set, or does the SelectObject method in NXOpen not inherit selection priority from the current session?
 
I'm revisiting this some today. I guess what I really want to do is filter out any solid body that's part of a component. That way I can either select entire components, or solid bodies within that part file.
 
Just found THIS from Baker that uses keyboard shortcuts to set the top selection priority in the session. Any ideas what that's doing behind the scenes?
 
The selection priority ranks the objects available for selection and gives preferential treatment to whatever type you have prioritized. The selection filter limits your selection choices; the selection priority ranks the available options.

For example: if your selection filter is set to none and the selection priority is set to edges, as you move the cursor over the model edges within the selection ball will highlight. If there are no edges within the selection ball, some other object type will highlight. If you pull up the selection list, any available edges will be at the top of the list; other object types will be lower in the list.

www.nxjournaling.com
 
Right. I should have been more specific. I tried recording a test journal to see what's going on with NXOpen and it doesn't give anything. I wasn't sure if there was a method in the Options class or something. The goal is to set the selection priority within the journal instead of making the user set it, because the default is not ideal.
 
Selection priority is a newer concept than the available selection functions. I don't know of a way to set selection priority through NXOpen (but of course that doesn't mean it isn't possible).

You may be able to do some custom filtering of your own...
The code below filters the selection for solid bodies. If the chosen body is an occurrence, the owning component is returned rather than the body itself.

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

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work

        Dim mySelection As TaggedObject
        If SelectObject("select a solid", mySelection) = Selection.Response.Cancel Then
            Exit Sub
        End If

        MsgBox("selection is a: " & mySelection.GetType.ToString)

    End Sub

    Function SelectObject(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response

        Dim theUI As UI = UI.GetUI
        Dim title As String = "Select an object"
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim cursor As Point3d
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
        Dim selectionMask_array(0) As Selection.MaskTriple

        With selectionMask_array(0)
            .Type = UFConstants.UF_solid_type
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
        End With

        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
         title, scope, selAction, _
         includeFeatures, keepHighlighted, selectionMask_array, _
         selobj, cursor)
        If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
            [highlight #FCE94F]Dim selBody As Body = selObj[/highlight]
            [highlight #FCE94F]If selBody.IsOccurrence Then[/highlight]
                [highlight #FCE94F]selObj = selBody.OwningComponent[/highlight]
            [highlight #FCE94F]End If[/highlight]
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If

    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

    End Function

End Module

www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor