7 Replies Latest reply on Nov 14, 2016 4:15 PM by E. G.

    List of Configurations - API Macro

    E. G.

      I am trying to get a list of the current configuration names of a part in order to populate those names in a comboBox (On a Form).

      I followed the example from : 2015 SOLIDWORKS API Help - Get List of Configurations Example (VBA)

      In the example, it spits out the configuration names using a msgbox. I need to put it in an array and then populate that into the comboBox so that the user can select which configuration they would like to make the changes to.

      The issue with my code is that only the last configuration is being listed (I'm assuming that the UBound has something to do with it?)

      How can i rewrite the code so that the list will populate correctly?



      Private Sub getconfignamesbutton_Click()

      Dim configArray() As Variant

      Dim swConfig As Configuration

      Set SwApp = Application.SldWorks

      Set swModel = SwApp.ActiveDoc

      Set swConfig = swModel.GetActiveConfiguration


      If Not swConfig Is Nothing And newconfigcheckbox.value = False Then

          configComboBox.Locked = False


                  configNames = swModel.GetConfigurationNames

      For i = 0 To UBound(configNames)

          configName = configNames(i)

              Set swConfig = swModel.GetConfigurationByName(configName)

                  'MsgBox ("Config Name:(" & i & ") = " + configName)

                       configArray = Array(configNames)

          Next i

              MsgBox ("You may now select a Configuration")

                 configComboBox.List = configArray


              MsgBox ("Unselect New Configuration")

      End If

      End Sub