I am working on a macro to cycle through all configurations of a given document and force rebuild each one. I found the code (below) for the basics on the SW API help site. It works great except for one minor issue.
I need the macro to reset the active configuration to the original configuration (whichever was active when the macro was started) after it has rebuilt the last one.
Currently it will cycle through all configurations and, once the last one has been rebuilt it remains the active configuration.
Here is the code I am working with:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim vConfNameArr As Variant
Dim sConfigName As String
Dim start As Single
Dim i As Long
Dim bShowConfig As Boolean
Dim bRebuild As Boolean
Dim bRet As Boolean
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Debug.Print "File = " + swModel.GetPathName
vConfNameArr = swModel.GetConfigurationNames
For i = 0 To UBound(vConfNameArr)
sConfigName = vConfNameArr(i)
bShowConfig = swModel.ShowConfiguration2(sConfigName)
start = Timer
bRebuild = swModel.ForceRebuild3(False)
Debug.Print " Configuration = " & sConfigName
Debug.Print " ShowConfig = " & bShowConfig
Debug.Print " Rebuild = " & bRebuild
Debug.Print " Time = " & Timer - start & " seconds"
Thanks in advance!!