4 Replies Latest reply on Dec 6, 2018 10:18 AM by Steve Fye

    How to delete all configs (except active one) FAST?

    Steve Fye

      I have a macro that I'm running from Excel... I've already got swPassedModel established and such, but here's the code that I'm trying to optimize:


      Dim vConfName, vConfParam, vConfValue As Variant
      Dim NumberOfConfigs As Integer
      Set swConfigMgr = swPassedModel.ConfigurationManager
      vConfName = swPassedModel.GetConfigurationNames
      For i = 0 To UBound(vConfName)
           bret = swConfigMgr.GetConfigurationParams(vConfName(i), vConfParam, vConfValue)
           Debug.Assert bret
           If vConfName(i) <> SolidWorksCurrentConfigurationOpened Then
                bret = swPassedModel.Extension.SelectByID2(vConfName(i), "CONFIGURATIONS", 0, 0, 0, True, 0, Nothing, 0)
           End If
      Next i


      The code works just fine, but it's really really slow compared to selecting all configs in SW manually and pressing the DELETE key.  For example, a part with about 300 configs takes about 45 seconds to delete using this code.  Only takes about 1 second if done manually.


      Is there another way I can do this to make this a faster process?  I've already tried using DeleteConfiguration2, and it's slower than what I have here.


      Thanks for any suggestions!