Auto add new configs to design table

I am trying to get the design table to update and add the new config after it is added. AutoAddNewConfigs sounds like it should do just that "Gets or sets whether to automatically add rows or columns to the design table when new configurations are added to the model." I have it set to true and the design table pops up but the new config is not added. Am I misunderstanding what AutoAddNewConfigs does or just using it wrong?

Thanks.

David

    Dim swApp As SldWorks.SldWorks

    Dim swModel As SldWorks.ModelDoc2

    Dim ConfigList As Variant

    Dim i As Integer

    Dim myConfigToTest As String

    Dim doesItExist As Boolean

    Dim swDT As SldWorks.DesignTable

    

        

Private Sub AddPartButton_Click()

     

    'Connect to SolidWorks, the active document, and Design Table

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swDT = swModel.GetDesignTable

     

     

    'Set new config to test

    myConfigToTest = UCase(PartNoInput.Text)

    doesItExists = False

         

         

    'Get list of configurations

    ConfigList = swModel.GetConfigurationNames

   

   

    'Test if configList contains user input.

    For i = 0 To UBound(ConfigList)

        If ConfigList(i) = myConfigToTest Then doesItExist = True

        Next

   

     If doesItExist Then

            MsgBox "That part number already exists."

            Exit Sub

       End If

          

    'Add new config and update design table

    swDT.Attach

    swDT.AutoAddNewConfigs = True

    swModel.AddConfiguration3 myConfigToTest, Empty, Empty, 0

    swModel.ForceRebuild3 True

   

   End Sub

SolidworksApi macros
Answers 4
PO
PO 2013-06-18 Best Answer

AutoAddNewConfigs is looking at the setting that is available when you create your design table (or edit the feature).  It lets you turn that setting on or off.  If the setting is turned on, the design table will add rows for new configs when you open it.  It doesn't, however, add them to the DT as soon as they are created.

SF
SF 2013-06-19

Patrick,

I now understand what that is doing, thanks.

I guess what I really am asking is how to update the DT? The config is added and the DT opens up but the DT does not update and the config is not added so I must be missing something. I have looked at and tried most of the other design tables API calls but none have worked for updating the table yet. Anyone have any idaes?

Thanks,

David

ST
ST 2013-06-19

I notice 2 methods on the DesignTable object:

UpdateModel Applies the edits to the design table to the model.  

UpdateTable Applies the changes made to the design table to the model.  

I haven't used it myself, but I'm guessing that UpdateTable is the one you want to use (with your swDT variable).

SF
SF 2013-06-19

Simon,

The way they read they both update the model with changes made to the DT. I need it the other way around, update the DT with the changes made to the model, the new config. I have tried both and they did not work or I did not use it right.

Thanks,

David