10 Replies Latest reply on Jan 9, 2019 3:27 PM by Layne Fowler

    How to add new configuration to design table

    Layne Fowler

      I can't find any function to add an existing configuration to a design table. Usually, once a configuration is added through the configuration manager I will have to edit the design table manually (right click design table -> "Edit Table"). At this point it asks me which configurations I want to add to the design table:


      I wrote a macro that copied the properties from each config and duplicated them in the design table. This didn't work because Solidworks didn't seem to realize they were linked back to the already created configurations.


      How can I achieve this in a macro?



      1. Solidworks part is open with design table inserted.
      2. Design table allows model edits to update itself and only new configurations add new rows.
      3. Add a new configuration in the configuration manager (right click config manager -> "Add Configuration...").



      1. Row is added to design table for new configuration.
      2. Configuration icon has changed to an Excel icon.
        • Re: How to add new configuration to design table
          Josh Helman

          Are you trying to update the design table with your new configurations? or add new custom properties to the design table?

          • Re: How to add new configuration to design table
            Rob Edwards

            Hi Layne

            Ive never personally used any of the API relating to design tables, but could you update the dt directly using

            2016 SOLIDWORKS API Help - AddRow Method (IDesignTable)

            2016 SOLIDWORKS API Help - Add Row to Design Table Example (VBA)

              • Re: How to add new configuration to design table
                Layne Fowler

                I tried using AddRow but I had some issues. I created an array for each configuration with the properties I needed in the table and could add them into the table. But there was no way to determine if the configuration was already in the table without diving into excel functions and comparing data. Without that information, the same config would get added to the table each time the macro is run.


                Also, the other issue with that method is that when you go to edit the table manually, the "Add Rows and Columns" box pops up (see image from my original post) as if the row and configuration aren't actually linked.


                Here is the proof of concept of the code I was using for that:


                Dim swApp As SldWorks.SldWorks
                Dim swModel As SldWorks.ModelDoc2
                Dim swDesignTable As DesignTable
                Dim swModelDocExt As SldWorks.ModelDocExtension
                Dim swCustProp As CustomPropertyManager
                Dim ConfigProp(3) As String
                Dim ConfigNumber As String
                Dim ConfigRev As String
                Dim ConfigDesc As String
                Dim ConfigNote As String
                Dim bRet As Boolean
                Dim iRet As Integer
                Dim ValOut As String
                Dim ResolvedValOut As String
                Dim WasResolved As Boolean
                Dim LinkToProperty As Boolean
                Sub main()
                Set swApp = Application.SldWorks
                Set swModel = swApp.ActiveDoc
                Set swModelDocExt = swModel.Extension
                ConfigNumber = swModel.GetConfigurationNames(0)
                Set swCustProp = swModelDocExt.CustomPropertyManager(ConfigNumber)
                iRet = swCustProp.Get6("Revision", False, ValOut, ConfigRev, WasResolved, LinkToProperty)
                iRet = swCustProp.Get6("Description", False, ValOut, ConfigDesc, WasResolved, LinkToProperty)
                iRet = swCustProp.Get6("Note", False, ValOut, ConfigNote, WasResolved, LinkToProperty)
                ConfigProp(0) = ConfigNumber
                ConfigProp(1) = ConfigRev
                ConfigProp(2) = ConfigDesc
                ConfigProp(3) = ConfigNote
                Set swDesignTable = swModel.GetDesignTable
                swDesignTable.EditTable2 (False)
                bRet = swDesignTable.AddRow(ConfigProp)
                bRet = swDesignTable.UpdateTable(2, True)
                End Sub