DesEngineer4
Mechanical
- Feb 19, 2013
- 181
Hi all,
I am using the below journal to create a new reference set "S" and move all the assembly components to that reference set. And it will show the an error popup like reference set exists, if there is already a reference set 's'. But, I am facing a problem with this journal. If i execute this journal multiple times it was creating duplicate reference set as shown in attachment. Kindly advice me in resolving this issue.
Thanks & Regards,
Sam
I am using the below journal to create a new reference set "S" and move all the assembly components to that reference set. And it will show the an error popup like reference set exists, if there is already a reference set 's'. But, I am facing a problem with this journal. If i execute this journal multiple times it was creating duplicate reference set as shown in attachment. Kindly advice me in resolving this issue.
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")
Dim referenceSet1 As ReferenceSet
referenceSet1 = workPart.CreateReferenceSet()
referenceSet1.SetName("S")
'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