How to find intersecting faces.

How to find intersecting faces.

praveen.cMXB2H
Enthusiast Enthusiast
234 Views
3 Replies
Message 1 of 4

How to find intersecting faces.

praveen.cMXB2H
Enthusiast
Enthusiast

praveencMXB2H_0-1702384498306.png

I want to highlight only the faces which are intersecting. With using below code i am able to get interference between parts and highlite the parts completly.

 

 

Dim oDoc As AssemblyDocument
Dim app As Inventor.Application = Marshal.GetActiveObject("Inventor.Application")
oDoc = app.ActiveDocument
Dim oSelectedOccs As ObjectCollection
oSelectedOccs = app.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
Dim oResults As InterferenceResults
Dim oCheckSet As ObjectCollection
oCheckSet = app.TransientObjects.CreateObjectCollection
If oSelectedOccs.Count = 0 Then
Dim oOcc As ComponentOccurrence
For Each oOcc In oDoc.ComponentDefinition.Occurrences
oCheckSet.Add(oOcc)
Next
oResults = oDoc.ComponentDefinition.AnalyzeInterference(oCheckSet)
ElseIf oSelectedOccs.Count = 1 Then
For Each oOcc In oDoc.ComponentDefinition.Occurrences
If Not oOcc Is oSelectedOccs.Item(1) Then
oCheckSet.Add(oOcc)
End If
Next
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
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
oResults = oDoc.ComponentDefinition.AnalyzeInterference(oSelectedOccs, oCheckSet)
Else
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
oHS1 = oDoc.HighlightSets.Add
oHS1.Color = app.TransientObjects.CreateColor(255, 0, 0)
Dim oHS2 As HighlightSet
oHS2 = oDoc.HighlightSets.Add
oHS2.Color = app.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
oHS2.Clear()
Else
MsgBox("There is no interference.")
End If

 

 

//But i want to get only the faces which are intersecting like below pic.

 

praveencMXB2H_1-1702384776388.png

 

 

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

WCrihfield
Mentor
Mentor

It is not designed to return faces.  We can only get what the InterferenceResult object gives us.

InterferenceResult.Centroid 

InterferenceResult.InterferenceBody 

InterferenceResult.OccurrenceOne 

InterferenceResult.OccurrenceTwo 

InterferenceResult.Volume 

The closest would be the InterferenceBody property, which returns a SurfaceBody, then iterate through its SurfaceBody.Faces collection, inspecting each one somehow.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

Frederick_Law
Mentor
Mentor

By definition there are 4 intersected faces on each body.

Need more criteria to remove other intersected faces.

Face 1 and Face 2 are not the only intersected faces.

Message 4 of 4

praveen.cMXB2H
Enthusiast
Enthusiast

Hi WCrihfield,  

Thanks for your reply,

 

I tried some work arounds but not  succeeded.

Dim surfaceBdy As SurfaceBody = oResults.InterferenceBody()    //Going to the Inventor UI but not coming back to the code //

Dim FaceCol As FaceCollection

FaceCol = surfaceBdy.Faces

0 Likes