Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Reference Set

Status
Not open for further replies.

DesEngineer4

Mechanical
Feb 19, 2013
181
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:
[COLOR=#3465A4]

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 

[/color]

Thanks & Regards,
Sam
 
Replies continue below

Recommended for you

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor