How to check Interference between two Faces API Solidworks

Hi

I am working on 3D Model in Solidworks. I would like to know which function I have to use to check interference between two faces (from different component) in particular? If anyone has a macro, I am really interested.

Thank you for yours answers :)

Hello,

SolidWorks have a function for check Interferences in assembly : http://help.solidworks.com/2015/english/solidworks/sldworks/hidd_dve_interference.htm

Do you know this function ?

Hello,

Thank you for your answer. Yes I know this function, but I would like to check Interference automatically with a macro on Visual Basic For Application.

In this case, you can read this example : http://help.solidworks.com/2015/english/api/sldworksapi/run_interference_detection_example_vb.htm

And also results for the search in SolidWorks APi Web Help : http://help.solidworks.com/SearchEx.aspx?query=Interference&version=2015&lang=english&prod=api

Thank YouRemrem for the links. I had already seen the links. The first shows the interferences in the global assembly. What I want is the interference between two faces from different parts like Face1 of Body1 interfere with Face1 of Body2 for example. I searched on internet, I am not sure it's possible for face.

I try a macro but It doesn't work

Sub Interference()


Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swAssembly As SldWorks.AssemblyDoc
Dim swModelExt As SldWorks.ModelDocExtension
Dim swComp As SldWorks.Component2
Dim swComp1 As SldWorks.Component2
Dim swBody As SldWorks.Body2
Dim swModeler As SldWorks.Modeler
Sun swSelMgr As SldWorks.SelectionMgr
Dim CompArray() As SldWorks.Component2
Dim swSelData As SldWorks.SelectData

Declaration of variables

Dim OutputPath As String
Dim OutputFN As String
Dim Component As Variant
Dim Component1 As Variant
Dim Components As Variant
Dim Components1 As Variant
Dim Deselection As Boolean
Dim Deselection1 Ace Boolean
Dim arrBody As Variant
Dim arrFace As Variant
Dim arrBody1 As Variant
Dim arrFace1 As Variant
Dim a As Boolean
Dim i                           as Integer
Dim i1                          As Integer
Sun j                           As Long
Dim k                           As Integer
Dim k1                          As Integer
Dim Interference                   As Boolean
Dim bRet                        As Boolean

Cell1 = 1
Set swApp = Application.SldWorks

Set swModeler = swApp.GetModeler


'Use the active document
Set swModel = swApp.ActiveDoc

Set swAssembly = swModel

Set swModelExt = swModel.Extension

 Set swSelMgr = swModel.SelectionManager

Set swSelData = swSelMgr.CreateSelectData


 
Components = swAssembly.GetComponents(False)
Components1 = swAssembly.GetComponents(False)
 
' for each component (part) in the parts collection (Assembly)
For Each Component In Components
        Set swComp = Component
        If swComp.GetSuppression <> 0 Then
        arrBody = swComp.GetBodies2(0)
        End If

   For i = 0 To UBound(arrBody)
   Set swBody = arrBody(i)
   arrFace = swBody.GetFaces

        For k = 0 TB UBound(arrFace)
        Set swFace = arrFace(k)
      Set swEnt = swFace
      a = swEnt.Select4(True, swSelData)
    
   
  For Each Component1 In Components1
    Set swComp1 = Component1
    If swComp1.GetSuppression <> 0 Then
    arrBody1 = swComp1.GetBodies2(0)
    End If
   
   
   For i1 = 0 To UBound(arrBody1)
   Set swBody1 = arrBody1(i)
   arrFace1 = swBody1.GetFaces

        For k1 = 0 TB UBound(arrFace1)
        Set swFace1 = arrFace1(k1)
      Set swEnt1 = swFace1
      a1 = swEnt1.Select4(True, swSelData)
     

    Interference = swModeler.ICheckInterference3(swFace, swFace1, Nothing)
    Debug.Print "Interference"; Interference
    If swModel.GetEntityName(swFace) <> swModel.GetEntityName(swFace1) Then
    DeselectionFace = swEnt1.DeSelect()
    End If
   
    Next k1
    Next i1

    Next Component1

DeselectionFace1 = swEnt.DeSelect()

Next k
Next i
Next Component
  
   
End Sub