Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Analyze Interferance for entire assembly

4 REPLIES 4
Reply
Message 1 of 5
djohnson1976
725 Views, 4 Replies

Analyze Interferance for entire assembly

I would like to click a button while in my assembly and have a macro cycle through and check interference between each of my parts. If it did not find an interference it would tell you when it was complete. Upon finding an interference, it would make a list of all of the part files that had interference detected. Anyone thought of this? Is this capability already out there?

Dan
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: djohnson1976

Here's a VBA program that does it. It's fairly simple to do using the
AnalyzeInterference method.

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"
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
--
Brian Ekins
Autodesk Inventor API

wrote in message news:5123215@discussion.autodesk.com...
I would like to click a button while in my assembly and have a macro cycle
through and check interference between each of my parts. If it did not find
an interference it would tell you when it was complete. Upon finding an
interference, it would make a list of all of the part files that had
interference detected. Anyone thought of this? Is this capability already
out there?

Dan
Message 3 of 5
Anonymous
in reply to: djohnson1976

Dan,

I believe if you pre-select all the parts in the assembly (say in the browser) and then do Tools, Interference Analysis then you get a table of results as shown in the attached image.

Just making sure that it can be done through the UI. Thanks.

shekar
Message 4 of 5
jennypet
in reply to: djohnson1976

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
Message 5 of 5
jennypet
in reply to: djohnson1976

Hallo Brian,

i have a question to the interference results.

what should I do if I want to display the interference volume as red?

cause though the code above can I still not able to see the interference direktly.

thanks so much if you can provide me a advise!

Lin

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report