While working with assemblies in NX, your parts' reference sets can pick up a lot of junk. Ok, maybe the junk is perfectly good and useable geometry, but you often don't want to keep it where NX put it. These extras show up from operations like wave linking, working in context of an assembly, importing/exporting geometry, etc etc. The reference set dialog will gladly tell you how many objects are in a given reference set, but it stubbornly refuses to show you where they are. Wouldn't it be great if reference sets had a command similar to the part navigator's show or show parents?
Below is a journal that will show you all the objects in the reference set. If an object is hidden or on an invisible layer, the object will be shown or the layer will be made visible. When you run the journal, all the objects in the specified reference set will be visible and highlighted. The journal will prompt you to select objects; you can select any new objects to add to the reference set or deselect any objects you no longer want in the reference set. When you press OK, only the currently selected objects will remain in the reference set. There is a line near the beginning of the journal that tells it which reference set to look for, it is currently set to MODEL, a common reference set in NX. If you use a custom reference set, change this line of the journal to the name of your reference set.
' April 10, 2012 ' Purpose: journal to add/remove objects from a certain reference set ' This journal will unblank and/or show the layer for all objects ' in the reference set, this works in a similar manner to the ' "show" or "show parents" command in the part navigator. ' This allows all current members of the reference set to be seen ' to aid in deselection if necessary. ' ' Helpful when the reference set picks up unnecessary objects along the way ' due to working in context of the assembly, exporting temp geometry, wave linking, etc. ' ' Developed and tested on NX 7.5 ' www.NXJournaling.com Option Strict Off Imports System Imports NXOpen Imports NXOpen.UI Imports NXOpen.UF Module Select_ref_set Dim ufs As UFSession = UFSession.GetUFSession() ' These global variables are necessary Dim init_proc_ref As UFUi.SelInitFnT = AddressOf init_proc_body Dim refMembers(-1) As NXObject Dim refMemberTags() As Tag Dim theSession As Session = Session.GetSession() Dim lw As ListingWindow = theSession.ListingWindow Sub Main() 'Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim displayPart As Part = theSession.Parts.Display Dim myReferenceSets As ReferenceSet() myReferenceSets = workPart.GetAllReferenceSets() Dim theReferenceSet As ReferenceSet = Nothing '%%%%%%%%%% Change the following line to point to the name of your reference set %%%%%%%%%% Const whatRefSet As String = "MODEL" '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dim stateArray1(0) As Layer.StateInfo Dim i As Integer Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Start") lw.Open() For Each myRefSet As ReferenceSet In myReferenceSets If myRefSet.Name.ToUpper() = whatRefSet Then theReferenceSet = myRefSet refMembers = myRefSet.AskAllDirectMembers() i = 0 For Each myObject As DisplayableObject In refMembers myObject.Unblank() If (myObject.Layer <> 0) And (myObject.Layer <> workPart.Layers.WorkLayer) Then stateArray1(0).Layer = myObject.Layer stateArray1(0).State = Layer.State.Selectable workPart.Layers.ChangeStates(stateArray1, True) End If 'lw.WriteLine(myObject.GetType.ToString) ReDim Preserve refMemberTags(i) refMemberTags(i) = myObject.Tag i += 1 Next End If Next Dim refSetObjs() As DisplayableObject = select_objects("Select Objects for reference set:") If refSetObjs IsNot Nothing Then theReferenceSet.RemoveObjectsFromReferenceSet(theReferenceSet.AskAllDirectMembers()) theReferenceSet.AddObjectsToReferenceSet(refSetObjs) End If lw.Close() theSession.SetUndoMarkName(markId1, "Show Reference Set Objects") theSession.SetUndoMarkVisibility(markId1, Nothing, Session.MarkVisibility.Visible) End Sub Public Function select_objects(ByRef prompt As String) As DisplayableObject() Dim response As Integer = 0 Dim cnt As Integer = 0 Dim objs() As Tag = Nothing Dim user_data As System.IntPtr ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM) Try ufs.Ui.SelectWithClassDialog("Select Objects: ", prompt, _ UFConstants.UF_UI_SEL_SCOPE_WORK_PART, init_proc_ref, _ user_data, response, cnt, objs) Finally ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM) End Try If response <> UFConstants.UF_UI_OK Then Return Nothing End If If cnt = 0 Then Return Nothing Else Dim selObjs(cnt - 1) As DisplayableObject For ii As Integer = 0 To cnt - 1 ufs.Disp.SetHighlight(objs(ii), 0) selObjs(ii) = Utilities.NXObjectManager.Get(objs(ii)) Next Return selObjs End If End Function Public Function init_proc_body(ByVal select_ As IntPtr, _ ByVal userdata As IntPtr) As Integer 'add objects already in reference set to the selection list 'select_ is the pointer to the selection ufs.Ui.AddToSelList(select_, refMemberTags.Length, refMemberTags, True) Return UFConstants.UF_UI_SEL_SUCCESS 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

Comments
additional dialog to select reference set available in part
Hello!
Do you have an extended version of this script to select the reference set available in the active part?
The listed script shows the elements just from one hardcoded reference set.
Thanks for your help.
Kind regards, Martin