AnsweredAssumed Answered

Macro to export clearance detection into excel

Question asked by David Wright on Dec 14, 2012
Latest reply on May 1, 2013 by David Wright

Hi guys, please forgive me if I'm posting this in the wrong thread, but I'd like to see if there is a command to put in a macro that will allow the interference detection tool to scan for a clearance of "x.xx" within an assembly. I work with electrical PCB's that contain 1000's of components and I for thermal reasons I try to get as close to the components as I can with the enclosures we use. (mitigating clearance issues of course.) I need to export the clearance verification report into an excel file. What I have so far is the following; VBA:


Private Sub LoadInterferencesComponentsIntoSpreadsheet()

    Set swApp = Application.SldWorks

    Set swModelDoc = swApp.ActiveDoc

    Set swAssemblyDoc = swModelDoc

    Set pIntMgr = swAssemblyDoc.InterferenceDetectionManager


    vint = pIntMgr.GetInterferenceCount

     vint = pIntMgr.TreatSubAssembliesAsComponents


    ws.Range("D2").Value = "NO. OF INTERFERENCES = " & vint

    ws.Range("D2").Font.ColorIndex = 3

    ws.Range("D2").ColumnWidth = 35



    vintvol = pIntMgr.GetInterferences


    For col = LBound(vintvol) To UBound(vintvol)

    compvol = (vintvol(col).Volume) * 61023.744094732

    ws.Cells((col + 3), "C").Value = compvol

    Next col


    For x = LBound(vintvol) To UBound(vintvol)

    comp = vintvol(x).Components

    n = comp(0).Name2

    m = comp(1).Name2

    ws.Cells((x + 3), "A").Value = n

    ws.Cells((x + 3), "B").Value = m

    Next x




    sPathName = swModelDoc.GetPathName

    sPathName = Left(sPathName, Len(sPathName) - 6)

    sPathName = sPathName + "xls"


    ws.SaveAs sPathName ' The excel file will be saved in the same folder as the Assembly


End Sub


The problem with this code is it uses the InterferenceDetectionManager and I can't figure out a way to make it detect parts that are closer than "x.xx" apart.


Any ideas?