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:
<p>Dim vConfName, vConfParam, vConfValue As Variant</p><p>Dim NumberOfConfigs As Integer</p><p>Set swConfigMgr = swPassedModel.ConfigurationManager</p><p>vConfName = swPassedModel.GetConfigurationNames</p><p>For i = 0 To UBound(vConfName)</p><p> bret = swConfigMgr.GetConfigurationParams(vConfName(i), vConfParam, vConfValue)</p><p> Debug.Assert bret</p><p> If vConfName(i) <> SolidWorksCurrentConfigurationOpened Then</p><p> bret = swPassedModel.Extension.SelectByID2(vConfName(i), "CONFIGURATIONS", 0, 0, 0, True, 0, Nothing, 0)</p><p> End If</p><p>Next i</p><p>swPassedModel.EditDelete</p>
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!
SolidworksApi/macros