kr7530
Automotive
- Aug 9, 2011
- 130
Can anybody help me with this? I am working on a journal that that checks for specific reference sets and if found it clears them of all objects. Then I create and/or populate them with user selections. The problem I am having is that the program works fine if it has to create the reference sets. If runs without errors if the reference sets already exist but it populates them incorrectly.
It should be 2 entities in the "FORMS" ref set, 1 entity in the "LWR" and 1 in the "UPR". I am getting 0 in the "FORMS" and in the "LWR" but 2 in the "UPR"
Any help would be greatly appropriated!
Thanks,
Kevin
NX8.0
'------------------Create and/or Populate Reference Sets----------------------------------------------------------------------
Dim myRefSet11 As ReferenceSet
Dim myRefSet22 As ReferenceSet
Dim myRefSet33 As ReferenceSet
Dim theReferenceSet11 As ReferenceSet
Dim theReferenceSet22 As ReferenceSet
Dim theReferenceSet33 As ReferenceSet
Dim found as Boolean = False
Dim found2 as Boolean = False
Dim found3 as Boolean = False
'------------------------------Forms Reference Set Population----------------------------------------
For Each myRefSet11 In workPart.GetAllReferenceSets()
If myRefSet11.Name.ToUpper() = "FORMS" Then
found = True
End If
Next
If Not found Then
theReferenceSet11 = workPart.CreateReferenceSet()
theReferenceSet11.SetName("FORMS")
theReferenceSet11.AddObjectsToReferenceSet(mySelections)
theReferenceSet11.AddObjectsToReferenceSet(mySelections2)
Else If found = True
theReferenceSet11 = myRefSet11
theReferenceSet11.AddObjectsToReferenceSet(mySelections)
theReferenceSet11.AddObjectsToReferenceSet(mySelections2)
End If
'------------------------------Lower Reference Set Population----------------------------------------
For Each myRefSet22 In workPart.GetAllReferenceSets()
If myRefSet22.Name.ToUpper() = "LWR" Then
found2 = True
End If
Next
If Not found2 Then
theReferenceSet22 = workPart.CreateReferenceSet()
theReferenceSet22.SetName("LWR")
theReferenceSet22.AddObjectsToReferenceSet(mySelections)
Else If found2 = True
theReferenceSet22 = myRefSet22
theReferenceSet22.AddObjectsToReferenceSet(mySelections)
End If
'------------------------------Upper Reference Set Population----------------------------------------
For Each myRefSet33 In workPart.GetAllReferenceSets()
If myRefSet33.Name.ToUpper() = "UPR" Then
found3 = True
End If
Next
If Not found3 Then
theReferenceSet33 = workPart.CreateReferenceSet()
theReferenceSet33.SetName("UPR")
theReferenceSet33.AddObjectsToReferenceSet(mySelections2)
Else If found3 = True
theReferenceSet33 = myRefSet33
theReferenceSet33.AddObjectsToReferenceSet(mySelections2)
End If
End Sub
It should be 2 entities in the "FORMS" ref set, 1 entity in the "LWR" and 1 in the "UPR". I am getting 0 in the "FORMS" and in the "LWR" but 2 in the "UPR"
Any help would be greatly appropriated!
Thanks,
Kevin
NX8.0
'------------------Create and/or Populate Reference Sets----------------------------------------------------------------------
Dim myRefSet11 As ReferenceSet
Dim myRefSet22 As ReferenceSet
Dim myRefSet33 As ReferenceSet
Dim theReferenceSet11 As ReferenceSet
Dim theReferenceSet22 As ReferenceSet
Dim theReferenceSet33 As ReferenceSet
Dim found as Boolean = False
Dim found2 as Boolean = False
Dim found3 as Boolean = False
'------------------------------Forms Reference Set Population----------------------------------------
For Each myRefSet11 In workPart.GetAllReferenceSets()
If myRefSet11.Name.ToUpper() = "FORMS" Then
found = True
End If
Next
If Not found Then
theReferenceSet11 = workPart.CreateReferenceSet()
theReferenceSet11.SetName("FORMS")
theReferenceSet11.AddObjectsToReferenceSet(mySelections)
theReferenceSet11.AddObjectsToReferenceSet(mySelections2)
Else If found = True
theReferenceSet11 = myRefSet11
theReferenceSet11.AddObjectsToReferenceSet(mySelections)
theReferenceSet11.AddObjectsToReferenceSet(mySelections2)
End If
'------------------------------Lower Reference Set Population----------------------------------------
For Each myRefSet22 In workPart.GetAllReferenceSets()
If myRefSet22.Name.ToUpper() = "LWR" Then
found2 = True
End If
Next
If Not found2 Then
theReferenceSet22 = workPart.CreateReferenceSet()
theReferenceSet22.SetName("LWR")
theReferenceSet22.AddObjectsToReferenceSet(mySelections)
Else If found2 = True
theReferenceSet22 = myRefSet22
theReferenceSet22.AddObjectsToReferenceSet(mySelections)
End If
'------------------------------Upper Reference Set Population----------------------------------------
For Each myRefSet33 In workPart.GetAllReferenceSets()
If myRefSet33.Name.ToUpper() = "UPR" Then
found3 = True
End If
Next
If Not found3 Then
theReferenceSet33 = workPart.CreateReferenceSet()
theReferenceSet33.SetName("UPR")
theReferenceSet33.AddObjectsToReferenceSet(mySelections2)
Else If found3 = True
theReferenceSet33 = myRefSet33
theReferenceSet33.AddObjectsToReferenceSet(mySelections2)
End If
End Sub