×
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 Sets with Journaling

Reference Sets with Journaling

Reference Sets with Journaling

(OP)
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

RE: Reference Sets with Journaling

CODE

For Each myRefSet11 In workPart.GetAllReferenceSets()
If myRefSet11.Name.ToUpper() = "FORMS" Then
found = True
End If
Next 

When this loop finishes, myRefSet11 will point to the last reference set in the collection. For instance, let's say you have ref1, ref2, FORMS, and ref3; at the end of the loop, myRefSet11 will point to ref3. Later, you set

CODE

theReferenceSet11 = myRefSet11 
so now, theReferenceSet11 also points to ref3.

Instead, try this:

CODE

For Each myRefSet11 In workPart.GetAllReferenceSets()
  If myRefSet11.Name.ToUpper() = "FORMS" Then
    theReferenceSet11 = myRefSet11
    found = True
    'stop looping, we found it
    exit for
  End If
Next 

www.nxjournaling.com

RE: Reference Sets with Journaling

(OP)
cowski,
Thanks again!

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