Interference Analysis

Interference Analysis

jbwaiteG7526
Contributor Contributor
806 Views
3 Replies
Message 1 of 4

Interference Analysis

jbwaiteG7526
Contributor
Contributor

I have a large assembly made of many parts.  Is there a way to perform an interference analysis between all of the parts ?  In the inspect tab, the analyze function, you can only select 2 groups or parts to analyze.  I would like to perform the analysis so that it will show up any interference between any two parts.  Can this be done and if so how ?

Jim

0 Likes
807 Views
3 Replies
Replies (3)
Message 2 of 4

Lewis.Young
Collaborator
Collaborator

Hello,

 

Here's some code for VBA (not iLogic) that will show each individual interference:

 

SyntaxEditor Code Snippet

Public Sub Interference()
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    ' Find all selected occurrences and add them to an ObjectCollection.
    Dim oSelectedOccs As ObjectCollection
    Set oSelectedOccs = ThisApplication.TransientObjects.CreateObjectCollection
    Dim i As Long
    For i = 1 To oDoc.SelectSet.Count
        If oDoc.SelectSet.Item(i).Type = kComponentOccurrenceObject Then
            oSelectedOccs.Add oDoc.SelectSet.Item(i)
        End If
    Next
    
    ' If no occurrences are selected check for interference of
    ' all parts against all parts.  If one occurrence is selected, check
    ' for interference between that occurrence and the rest of the assembly.
    ' If more than one occurrence is selected let the user decide if it
    ' should check for interference between the parts in the selection or
    ' between the selected parts and the rest of the assembly.
    Dim oResults As InterferenceResults
    Dim oCheckSet As ObjectCollection
    Set oCheckSet = ThisApplication.TransientObjects.CreateObjectCollection
    If oSelectedOccs.Count = 0 Then
        ' Add all occurrences to the object collection
        Dim oOcc As ComponentOccurrence
        For Each oOcc In oDoc.ComponentDefinition.Occurrences
            oCheckSet.Add oOcc
        Next
        
        ' Get the interference between everything.
        Set oResults = oDoc.ComponentDefinition.AnalyzeInterference(oCheckSet)
    ElseIf oSelectedOccs.Count = 1 Then
        ' Add all occurrences except the selected occurrence to the object collection.
        For Each oOcc In oDoc.ComponentDefinition.Occurrences
            If Not oOcc Is oSelectedOccs.Item(1) Then
                oCheckSet.Add oOcc
            End If
        Next
        
        ' Get the interference between the selected occurrence everything else.
        Set oResults = oDoc.ComponentDefinition.AnalyzeInterference(oSelectedOccs, oCheckSet)
    Else
        If MsgBox("Check interference between selected occurrences and all other occurrences?", vbYesNo + vbQuestion) = vbYes Then
            ' Add all occurrences except the selected occurrences to the object collection.
            For Each oOcc In oDoc.ComponentDefinition.Occurrences
                ' Check to see if this occurrences is already selected.
                Dim bSelected As Boolean
                bSelected = False
                For i = 1 To oSelectedOccs.Count
                    If oSelectedOccs.Item(i) Is oOcc Then
                        bSelected = True
                        Exit For
                    End If
                Next
                
                If Not bSelected Then
                    oCheckSet.Add oOcc
                End If
            Next
           
            ' Check interference between the selected items.
            Set oResults = oDoc.ComponentDefinition.AnalyzeInterference(oSelectedOccs, oCheckSet)
        Else
            ' Check interference between the selected items.
            Set oResults = oDoc.ComponentDefinition.AnalyzeInterference(oSelectedOccs)
        End If
    End If
    
    If oResults.Count = 1 Then
        MsgBox "There is 1 interference."
    ElseIf oResults.Count > 1 Then
        MsgBox "There are " & oResults.Count & " interferences."
    End If
    
    If oResults.Count > 0 Then
        Dim oHS1 As HighlightSet
        Set oHS1 = oDoc.HighlightSets.Add
        oHS1.Color = ThisApplication.TransientObjects.CreateColor(255, 0, 0)
        Dim oHS2 As HighlightSet
        Set oHS2 = oDoc.HighlightSets.Add
        oHS2.Color = ThisApplication.TransientObjects.CreateColor(0, 255, 0)
        
        For i = 1 To oResults.Count
            oHS1.Clear
            oHS2.Clear
            oHS1.AddItem oResults.Item(i).OccurrenceOne
            oHS2.AddItem oResults.Item(i).OccurrenceTwo
            MsgBox "Occurrences are highlighted from interference " & i
        Next
        
        oHS1.Clear
        oHS2.Clear
    Else
        MsgBox "There is no interference."
    End If
End Sub

If you need help on using VBA, just let me know!

 

Lewis Young
Windows 7 x64 - 32GB Ram
Intel Xeon E5-1620 v2 @ 3.70GHz
nVidia Quadro M2000 - 4GB
Inventor Professional 2017.3
Vault Basic 2017
3ds Max 2018

Message 3 of 4

jtylerbc
Mentor
Mentor

The key thing you're missing is that there's no rule that says the same parts can't be in both selection sets.  Just box-select everything in the assembly before hitting the "Analyze Interference" button.  This puts all objects in both sets, resulting in an interference analysis that includes everything in the assembly.

 

Or if selecting the components first is hard for you to remember to do, you can also achieve the same thing by box-selecting everything for both selection sets.  Which method you use doesn't affect the results.

Message 4 of 4

stephenrottloff7259
Advocate
Advocate

In Inventor 2018, when I use the Inspect > Analyze Interference command, I ignore the 2 group option and just window select everything within an assembly.  This is a quick way to report any interference.  Then I change the view mode to wireframe to locate the highlighted interferences within the assembly.  If the interferences are too small, then I click on the magnifying glass within the interference report listing window.  That zooms in on the interference.

 

 

Thank you,

Stephen R.