Inventor Customization

Inventor Customization

Reply
Distinguished Contributor
djohnson1976
Posts: 319
Registered: ‎01-20-2006
Message 1 of 5 (404 Views)

Analyze Interferance for entire assembly

404 Views, 4 Replies
03-27-2006 12:26 PM
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
*Brian Ekins \(Autodesk\)
Message 2 of 5 (404 Views)

Re: Analyze Interferance for entire assembly

03-27-2006 03:50 PM 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
Distinguished Contributor
shekarsub[Autodesk]
Posts: 2,198
Registered: ‎05-09-2005
Message 3 of 5 (404 Views)

Re: Analyze Interferance for entire assembly

01-06-2007 05:23 AM 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
Contributor
jennypet
Posts: 13
Registered: ‎11-13-2009
Message 4 of 5 (404 Views)

Re: Analyze Interferance for entire assembly

11-13-2009 01:24 AM 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
Contributor
jennypet
Posts: 13
Registered: ‎11-13-2009
Message 5 of 5 (404 Views)

Re: Analyze Interferance for entire assembly

11-17-2009 01:11 AM 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.