Code:
Sub CatMain()
'Select the Parts
Set selection1 = CATIA.ActiveDocument.Selection
selection1.Search "Type=Part & Name = *,all" 'Suche nach den Parts
'Retrieve the Clashes collection
Dim cClashes As Clashes
Set cClashes = CATIA.ActiveDocument.Product.GetTechnologicalObject("Clashes")
'Create a clash with selected components and compute it
Dim oClash As Clash
Set oClash = cClashes.AddFromSel
oClash.ComputationType = catClashComputationTypeAgainstAll 'or ...XXX other rules
oClash.InterferenceType = catClashInterferenceTypeClearance 'or ...Contact without Clearance
oClash.Clearance = 5 'Insert clearance value
oClash.Compute
'Filter conflicts
Dim cConflicts As Conflicts
Set cConflicts = oClash.Conflicts
Dim I As Integer
For I = 1 To cConflicts.Count
Dim oConflict As Conflict
Set oConflict = cConflicts.Item(I)
If (oConflict.Type = catConflictTypeClearance) Then
oConflict.Status = catConflictStatusRelevant
oConflict.Comment = "Clearance fell below " & oClash.Clearance & "mm"
ElseIf (oConflict.Type = catConflictTypeContact) Then
oConflict.Status = catConflictStatusRelevant
oConflict.Comment = "Contact"
ElseIf (oConflict.Type = catConflictTypeClash) Then
oConflict.Status = catConflictStatusRelevant
oConflict.Comment = "Clash " & Int(oConflict.Value * 100) / 100 & "mm" 'Value with two decimal places
End If
Next
'MsgBox Output if no Conflict was detected
If (cConflicts.Count = 0) Then
MsgBox "No Conflicts.", vbInformation, "Output"
End If
End Sub
'Only for Information, if desired
'Export als .xml
'Dim ThePath As String
'oClash.Export CatClashExportTypeXMLResultOnly, "Dateiname mit Pfad"