Hallo,
how did you make the interfering occurrences to display as red?
I use the following code to change the interfering occurences color, but i get the whole subassembly's also the part's color changed.
Public Sub FindInterference()
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = oAsmDoc.ComponentDefinition
' Add each occurrence in the assembly to the object collection.
Dim oCheckSet As ObjectCollection
Set oCheckSet = ThisApplication.TransientObjects.CreateObjectCollection
Dim oOcc As ComponentOccurrence
For Each oOcc In oAsmCompDef.Occurrences
oCheckSet.Add oOcc
Next
' Call the AnalyzeInterference method, passing in a single
' collection. This will cause it to compare everything against
' everything else.
Dim oResults As InterferenceResults
Set oResults = oAsmCompDef.AnalyzeInterference(oCheckSet)
' Display the results of the interference.
Debug.Print "Interferences found: " & oResults.Count
Dim oResult As InterferenceResult
Dim iCount As Integer
iCount = 0
For Each oResult In oResults
iCount = iCount + 1
Debug.Print " Interference " & iCount
Debug.Print " Occurrence 1: " & FullOccurrenceName(oResult.OccurrenceOne)
Debug.Print " Occurrence 2: " & FullOccurrenceName(oResult.OccurrenceTwo)
Debug.Print " Volume: " & oResult.Volume & " cm^3"
Dim oOccChange As ComponentOccurrence
Set oOccChange = oResult.OccurrenceTwo
MsgBox " Interference " & iCount & " ; Occurrence 1: " & FullOccurrenceName(oResult.OccurrenceOne) & "Occurrence 2: " & FullOccurrenceName(oResult.OccurrenceTwo) & " Volume: " & oResult.Volume & " cm^3"
'MsgBox " Occurrence 1: " & FullOccurrenceName(oResult.OccurrenceOne)
'MsgBox " Occurrence 2: " & FullOccurrenceName(oResult.OccurrenceTwo)
'MsgBox " Volume: " & oResult.Volume & " cm^3"
'MsgBox "Type" & oResult.Type
Call oOccChange.SetRenderStyle(kOverrideRenderStyle, oAsmDoc.RenderStyles.Item(14))
Next
End Sub
' Used to display the full path of an occurrence. This is the path of the
' occurrence within the assembly structure.
Private Function FullOccurrenceName(Occ As ComponentOccurrence) As String
Dim i As Integer
For i = 1 To Occ.OccurrencePath.Count
If i = 1 Then
FullOccurrenceName = Occ.OccurrencePath.Item(i).Name
Else
FullOccurrenceName = FullOccurrenceName & "\" & Occ.OccurrencePath.Item(i).Name
End If
Next
End Function
how can I only change the interfering part's color?
thank you so much!!
Edited by: jennypet on Nov 17, 2009 9:15 AM