2 Replies Latest reply on May 1, 2013 12:12 PM by David Wright

    Export clearance verification report into excel

    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 theclearance 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?

        • Re: Export clearance verification report into excel
          David Wright

          I haven't had any time to explore more into this, but if it helps I found a lead for those reading this thread: swCommands_ClearanceVerification

          • Re: Export clearance verification report into excel
            David Wright

            I've been able to get a macro that works. The macro prompts the user for a desired clearance in mm, gives the user a choice to include solder (in the case it's an electronic board inside an enclosure), and then spits out a report in EXCEL all clearances of all components. If the user chooses not to analyse a particular part within the assembly, they simply need to suppress the part before running the macro. The report identifies all components that fail the clearance specified by the user and can then be used to manipulate/give to superiors.


            Excellant for design verification in a design report/package. If anyone is interested, please let me know.