I made a VBA macro that suppresses a component of an assembly via IConfigurationManager.SetConfigurationParams.
Here is the code (I also attached it):
Dim swApp As SldWorks.SldWorks
Dim activeDoc As ModelDoc2
Dim assyDoc As AssemblyDoc
Dim vComponents As Variant
Dim swComp As Component2
Dim compNameInstance As String
Dim key(0) As String
Dim vKeys As Variant
Dim val(0) As String
Dim vVals As Variant
Dim swConfMgr As SldWorks.ConfigurationManager
Dim swConf As SldWorks.Configuration
Dim confName As String
Dim success As Boolean
Set swApp = Application.SldWorks
Set activeDoc = swApp.activeDoc
Set assyDoc = activeDoc
vComponents = assyDoc.GetComponents(True)
Set swComp = vComponents(0)
compNameInstance = swComp.Name2
compNameInstance = Replace(compNameInstance, "-", "<") + ">"
key(0) = "$state@" + compNameInstance
val(0) = "S"
vKeys = key
vVals = val
Set swConfMgr = activeDoc.ConfigurationManager
Set swConf = swConfMgr.ActiveConfiguration
confName = swConf.Name
success = swConfMgr.SetConfigurationParams(confName, vKeys, vVals)
Debug.Print "success? -> "; success
It does what it should do, BUT: After it was run, it is not possible to unsuppress the component by hand. If I try, I get this:
This happens for all assemblies I tried so far - no matter if they have a design table or not. I attached two of them.
I have tried some things regarding the design table:
Get it via IModelDoc2.GetDesignTable().
Check if it is null. => Always false.
Check if it is active (IDesignTable.IsActive()). => Always false.
Check if it is updatable (IDesignTable.Updatable). => Always true.
Update it and check if updating was successful (IDesignTable.UpdateTable(2, true)). => Always successful (true).
Delete the Design Table (IModelDoc2.DeleteDesignTable).
Nothing solves the problem.
Any ideas or hints?
PS: This problem seems to be quite old (check Problem with DesignTable and ConfigurationManager )...