AnsweredAssumed Answered

How do I keep from creating new display states each time I add a new configuration?

Question asked by Adam Hoffman on Jan 20, 2015
Latest reply on Jan 20, 2015 by Adam Hoffman

I'm am using a macro to add a new configuration and when I do it keeps creating new display states each time I add a new configuration. I have the model set to not link configurations to display states, but it keeps adding new ones each time I create a new configuration with my add in. Does anyone know of a work around to this? Here is what I have so far:


Dim bAlreadyExists As Boolean = SeeIfConfigExists(swModel, sNewPartNo)


If bAlreadyExists = True Then
     MessageBox.Show("There Is Already A Configuration Named: " + sNewPartNo, "Part Number Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
     Exit Sub
End If


Dim swConfigMgr As SolidWorks.Interop.sldworks.ConfigurationManager = Nothing

swConfigMgr = swModel.ConfigurationManager


If Not swConfigMgr Is Nothing Then

     swConfigMgr.LinkDisplayStatesToConfigurations = False

End If


Dim swConfig As SolidWorks.Interop.sldworks.Configuration = swModel.GetActiveConfiguration


If UCase(swConfig.Name) = "DEFAULT" Then
        swConfig.Name = sNewPartNo
     Catch ConfigPropSetError As Exception
      End Try

      swModel.AddConfiguration3(sNewPartNo, "", "", swConfigurationOptions2_e.swConfigOption_HideByDefault)


      swConfig = swModel.GetActiveConfiguration

End If