Iterate Through All Configurations Example (VBA)
This example shows how to iterate through all of the configurations
in a document and forcibly rebuild each one. It assumed that you have
an active document.
'--------------------------------------
' Forcibly rebuild each configuration
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
vConfNameArr As
Variant
Dim
sConfigName As
String
Dim
nStart 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)
nStart
= Timer
bRebuild
= swModel.ForceRebuild3(False)
Debug.Print
" Config
=
" & sConfigName
Debug.Print
" ShowConfig
= " & bShowConfig
Debug.Print
" Rebuild
=
" & bRebuild
Debug.Print
" Time
=
" & Timer - nStart & " s"
Next
i
End Sub
'--------------------------------------