Private Sub CaptureRelationships_Click(sender As Object, e As EventArgs) Handles CaptureRelationships.Click
Dim objApplication As SolidEdgeFramework.Application
Dim objAsmDoc As SolidEdgeAssembly.AssemblyDocument
Dim objOccurrence As SolidEdgeAssembly.Occurrence
Dim objOccurrences As SolidEdgeAssembly.Occurrences
Dim NumberOfCapturedRelationships As Long
Dim arrayRelationships() As Object
Dim Count As Long
Dim objRelation As Object
Dim i, j As Integer
Try
' Create/get the application with specific settings
objApplication = Marshal.GetActiveObject("SolidEdge.Application")
' open the document mentioned in the doc files.
objAsmDoc = objApplication.ActiveDocument
objOccurrences = objAsmDoc.Occurrences
objOccurrence = objOccurrences.Item(2)
objOccurrence.ClearCapturedRelationships()
If objOccurrence.Relations3d.Count Then
If objOccurrence.Status = SolidEdgeAssembly.OccurrenceStatusConstants.seOccurrenceStatusUnderDefined Or objOccurrence.Status = SolidEdgeAssembly.OccurrenceStatusConstants.seOccurrenceStatusWellDefined Then
Count = 0
For Each objRelation In objOccurrence.Relations3d
Count = Count + 1
Next
If (Count <> 0) Then
ReDim arrayRelationships(Count)
For j = 1 To Count
arrayRelationships(j - 1) = objOccurrence.Relations3d(j)
Next
' Capture the relationships
objOccurrence.CaptureRelationships(Count, arrayRelationships)
If Err.Number Then
MsgBox("Could not capture relationships for " & objOccurrence.Name)
End If
End If
End If
End If
NumberOfCapturedRelationships = objOccurrence.OccurrenceDocument.CapturedRelationshipCount
Catch ex As Exception
MsgBox(ex.ToString)
Clipboard.SetText(ex.ToString)
End Try
End Sub