Hi,
Some time ago I worked on a similar problem. The method itself is ThisApplication.CommandManager.ControlDefinitions("AssemblyCompSuppressionCtxCmd").Execute()
but I applied it to each individual item in the folder by first checking whether the item was a ComponentOccurrence and what its current state was. I did this as a safety measure, because if you try to set ComponentOccurrence.Suppressed = False on a folder while one of the components inside that folder has ComponentOccurrence.Suppressed = True, then calling
ThisApplication.CommandManager.ControlDefinitions("AssemblyCompSuppressionCtxCmd").Execute()
will always switch the components in the folder to Suppressed = True.
That’s why I iterated through every item in the folder, confirmed that each item was a ComponentOccurrence and noted its state. Then, depending on what I needed, I added it to an ObjectCollection.
My method look like:
Sub Configurator(folderName As String, configurationPar As String, ByRef partToUnsuppress As ObjectCollection, ByRef partToSuppress As ObjectCollection)
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oModelBrowser As BrowserPaneObject = oDoc.BrowserPanes.Item("Model")
Dim oConfigurationFolder As BrowserFolder = oModelBrowser.TopNode.BrowserFolders.Item("_KONFIGURACJA_")
Dim mainFolder As BrowserFolder = oConfigurationFolder.BrowserNode.BrowserFolders.Item(folderName)
Dim foldersInsideMainFolder = mainFolder.BrowserNode.BrowserFolders
For Each folder As BrowserFolder In foldersInsideMainFolder
Dim nodesInFolder As BrowserNodesEnumerator = folder.BrowserNode.BrowserNodes
If folder.Name = configurationPar
For Each node As BrowserNode In nodesInFolder
If TypeOf node.NativeObject Is ComponentOccurrence And node.NativeObject.Suppressed = True
partToUnsuppress.Add(node.NativeObject)
End If
Next
Else
For Each node As BrowserNode In nodesInFolder
If TypeOf node.NativeObject Is ComponentOccurrence And node.NativeObject.Suppressed = False
partToSuppress.Add(node.NativeObject)
End If
Next
End If
Next
End Sub
If you found it helpful, a "Like" would be much appreciated!
If this post solved your problem, please mark it as "Solution.".