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 vb.net 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
    Try
        swConfig.Name = sNewPartNo
     Catch ConfigPropSetError As Exception
          Debug.WriteLine(ConfigPropSetError)
      End Try

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

      swModel.ShowConfiguration2(sNewPartNo)

      swConfig = swModel.GetActiveConfiguration

End If

Outcomes