×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX Open - Ref sets

NX Open - Ref sets

NX Open - Ref sets

(OP)
I'm trying to get the list of ref sets for each part open in my session.
So far I've only been able to find how to create a new ref set.

Anyone managed to do this?

Mark Benson
Aerodynamic Model Designer

To a Designer, the glass was right on CAD.

RE: NX Open - Ref sets

Since a Reference Set ONLY plays a role when working in the context of an Assembly, the better question would be; "How can I find out which Reference Set is being used for each Component part in my current Assembly?"  And you do that by opening the Assembly Navigator and making sure that you have toggled on the 'Reference Set' column.  And if you have sub-assemblies and you wish to see them as well, make sure the you've toggled on the 'Expand All' option.

John R. Baker, P.E.
Product 'Evangelist'
Product Design Solutions
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
http://www.siemens.com/plm
http://www.plmworld.com/museum/

To an Engineer, the glass is twice as big as it needs to be.
 

RE: NX Open - Ref sets

I just noticed that the title of your entry mentions 'NX Open'.  Obviously my responce was based on what you would do during an interactive session of NX.  Sorry for the confusion.

That being said, this should provide you a hint in that the command that you're looking for would be one which deals with the Components of an Assembly and not with the open Part file itself.

John R. Baker, P.E.
Product 'Evangelist'
Product Design Solutions
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
http://www.siemens.com/plm
http://www.plmworld.com/museum/

To an Engineer, the glass is twice as big as it needs to be.
 

RE: NX Open - Ref sets

(OP)
John,

Thanks for your reply.

What I'm trying to do is programatically find the ref sets that exist in a part so I can list them as options to the user in a form so they can select the correct ref set to add that part into an assembly.
I think I've now found the function which is part of the basepart class and hopefully works from workpart.  It's called "GetAllReferenceSets".

Mark Benson
Aerodynamic Model Designer

To a Designer, the glass was right on CAD.

RE: NX Open - Ref sets

Sounds like what you're looking for.  Good luck.

John R. Baker, P.E.
Product 'Evangelist'
Product Design Solutions
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
http://www.siemens.com/plm
http://www.plmworld.com/museum/

To an Engineer, the glass is twice as big as it needs to be.
 

RE: NX Open - Ref sets

MSPBenson,
I hope this will help.
    '-----------------------Searching the bodies in the ref set ----------------
    Public Function test() As Tag

        Dim theSession As Session = Session.GetSession()
        Dim theUFSession As UFSession = UFSession.GetUFSession()
        Dim theUI As UI = UI.GetUI()
        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        'lw.Open()
        Dim iBodies(0) As IBody
        Dim num_ref_sets As Integer = 0
        Dim ref_sets() As Tag = Nothing
        Dim ref_set_name As String = ""
        Dim origin(2) As Double
        Dim matrix(8) As Double
        Dim num_members As Integer
        Dim members() As Tag = Nothing
        Dim ref_set_name_to_edit As String
        Dim seedString As String = "MODEL"
        Dim bodies_found As Integer = 0
        Dim test_ertek_1 As NXObject = Nothing
        Dim test_ertek_2 As NXObject = Nothing
        Dim t_body As NXObject = Nothing

        'Dim t() As String
        'ReDim t(0)
        Dim i As Integer = 0
        Dim j As Integer = 0


        Dim ref_set As Tag = Nothing
        Dim ret_count As Integer = 0
        Dim mems_1 As Tag() = Nothing
        Dim mems_2 As Tag() = Nothing

        Dim v_ref_set As String

        Dim NULLTAG As Tag = NXOpen.Tag.Null
        Dim objectTag As Tag = NXOpen.Tag.Null

        Dim vissza As Tag = Nothing

        Try
            theUFSession.Obj.CycleObjsInPart(workPart.Tag, NXOpen.UF.UFConstants.UF_reference_set_type, objectTag)

            Do

                Dim myrefset As ReferenceSet = Nothing
                Dim myObject As NXObject = Nothing

                myObject = NXObjectManager.Get(objectTag)
                myrefset = CType(myObject, ReferenceSet)

                'MsgBox("Name = " & myrefset.Name)

                If myrefset.Name = "MODEL" Then
                    ref_set = myrefset.Tag
                    i = i + 1
                    theUFSession.Assem.AskRefSetMembers(ref_set, ret_count, mems_1)
                    'lw.WriteLine("---------" & mems_1(0))
                End If


                If myrefset.Name = "TRUE" Then

                    v_ref_set = myrefset.Name
                    ref_set = myrefset.Tag
                    j = j + 1
                    theUFSession.Assem.AskRefSetMembers(ref_set, ret_count, mems_2)
                    'lw.WriteLine("---------" & mems_2(0))
                End If

                theUFSession.Obj.CycleObjsInPart(workPart.Tag, NXOpen.UF.UFConstants.UF_reference_set_type, objectTag)


            Loop While objectTag <> NULLTAG



            If j = 1 Then
                vissza = mems_2(0)
                'MsgBox("Name = " & v_ref_set)
            Else
                vissza = mems_1(0)
            End If

            'test_ertek_1 = mems_1(0)
            'lw.WriteLine("this comes back: " & vissza)

            If i = 0 And j = 0 Then
                Return vissza
                Exit Function
            End If



        Catch ex As Exception
            'MsgBox("Nincs Hasab attributum definialva!" & ex.GetBaseException.ToString() & vbCrLf)
            'MsgBox("Nincs MODEL vagy TRUE refset!")
            'workPart.SetAttribute(db_part_title, db_part_ertek)

        End Try

        Return vissza

    End Function

RE: NX Open - Ref sets

This will do exactly what you're looking for and works on the NX Work Part:

Do

   ufs.Obj.CycleObjsInPart(s.Parts.Work.Tag, UFConstants.UF_reference_set_type, refset)

   If refset <> NXOpen.Tag.Null Then
      ufs.Obj.AskName(refset, name)
      ' cbbRefSet.Items.Add(name) ' this add the ref. set name to a combobox named "cbbRefSet"
   End If

Loop While refset <> NXOpen.Tag.Null
 

RE: NX Open - Ref sets

(OP)
Thanks to everyone who posted.
I'm writting this to sun in NX7.5 which has improved functioanality when compared to NX6.
I've looked befor in the NX6 help docs but never found it.  A quick look in the NX7.5 ones and ther it was.

My brief has changed slighlty now.  I want to click on a part in a list in my form and display it's relevant ref sets in a combo box.  I check if there is currently displayed value of ref set in the list and this is the input of "original"

Here's what I ended up with:

Private sub combobox_fill(byval original as string)
ComboBox1.Items.clear        
Dim myrow As DataGridViewRow
        myrow = DataGridView1.CurrentRow
        'MsgBox(myrow.cells(0).value)
Dim ref_check_part As Part = CType(theSession.Parts.FindObject("@DB/" & myrow.cells(0).value), Part)

'here's the important line for grabbing the ref sets of the part clicked on

dim  ref_set_list as referenceset() = ref_check_part.GetAllReferenceSets

dim ref_index as integer
for ref_index = 0 to ref_set_list.length-1

ComboBox1.Items.Add(ref_set_list(ref_index).name)
next

if ComboBox1.Items.Contains(original) = true then
ComboBox1.SelectedItem = combobox1.items.indexof(original)
ComboBox1.Text  = original


else
ComboBox1.SelectedItem = 0
ComboBox1.Text  = combobox1.items(0)
combobox1.refresh()

end if
end sub


This could easily be used in a loop to achieve the original question I posted above.  

Mark Benson
Aerodynamic Model Designer

To a Designer, the glass was right on CAD.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources