×
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

Reference Set

Reference Set

Reference Set

(OP)
Hi all,

I am using the below code to create Reference set "S" and to move all the assembly components to that reference set.

I need a correction in this journal. It is collecting all components and bodies and adding to s reference set.
But I need to eliminate para solids whose extension (.x_t) or if it is not possible then, it can eliminate all features and bodies from part
navigator only. But, it should collect all assembly components which are in assembly navigator and to add in reference set s.

Thanks in advance.



CODE -->



Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen

Module Module1

    Sub Main()

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

        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Create New Reference Set")
		
		Const newRefSetName As String = "S"
		Dim found as Boolean = False
		Dim myRefSet as ReferenceSet
		
		'check to see if reference set already exists
		For Each myRefSet In workPart.GetAllReferenceSets()
            If myRefSet.Name.ToUpper() = newRefSetName Then
				found = True
				Exit For
            End If
        Next
		
		Dim referenceSet1 As ReferenceSet
		
		If Not found Then
			'create new reference set
			referenceSet1 = workPart.CreateReferenceSet()
			referenceSet1.SetName(newRefSetName)
		Else
			'use the existing reference set
			referenceSet1 = myRefSet
		End If
		
        'add all components (existing and future)
        referenceSet1.SetAddComponentsAutomatically(True, True)
        'create list variable for solid bodies
        Dim mySolids As List(Of Body) = New List(Of Body)
        'workPart.Bodies collection contains both solid and sheet bodies
        'filter out solid bodies and add them to the list
        For Each solid As Body In workPart.Bodies
            If solid.IsSolidBody Then
                mySolids.Add(solid)
            End If
        Next
        'add solid bodies to reference set
        referenceSet1.AddObjectsToReferenceSet(mySolids.ToArray)

    End Sub


    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 

 

Thanks & Regards,
Sam

RE: Reference Set

And what 'value' do you expect to realize from placing 'Components' in a Reference Set?

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.

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