- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, quick question for you guys as I'm exploring some new VBA/iLogic territory... At the minute I'm attempting to model a configuration-type of work flow (we're still in 2020, plz don't ask why I'm exploring this when it's a feature in 2022... I've been asking for that version as well but no answer as to when we're going to get it...)
Currently I've got one assembly which contains many sub-assemblies that are organized into folders an a few patterns. Because each of the 8 required folder contains about 10 sub-assemblies, I'd prefer to start with an array and find all the folders in my design tree and suppress them (if using iLogic to return all the folders in the tree into an array is difficult then hard coding the folder strings into the array would be an option.) I'd prefer to start with everything suppressed because it would be easier, in my opinion, to state which value will be unsuppressed rather than declare the 7 values which will become suppressed.
Currently the code is as follows
Folder_Size = New String() {"16.88", "19.88", "22.88", "25.88", "28.88", "31.88", "34.88", "37.88"}
MultiValue.SetList("Compactor_Size", "16.88", "19.88", "22.88", "25.88") ', "28.88", "31.88", "34.88", "37.88")
MultiValue.SetList("Screen_Type","STR", "CF" )
MultiValue.SetList("Catch_Type", "Drain", "Drain2")
oApp = ThisApplication
oDoc = oApp.ActiveDocument
oPane = oDoc.BrowserPanes("Model")
oTopNode = oPane.TopNode
For Each In Folder_Size
'Define which folder to suppress
folder = oTopNode.BrowserFolders.Item(Folder_Size)
oSelectSet = oDoc.SelectSet
oSelectSet.Clear
'Select the folder automaticly
oSelectSet.Select(folder)
Dim oCommandMgr As CommandManager
oCommandMgr = oApp.CommandManager
'Toggle suppress or unsuppress
oCommandMgr.ControlDefinitions.Item("AssemblyCompSuppressionCtxCmd").Execute2(True)
Next
On Error Resume Next
I do not know the syntax for the For loop here. For each... what, I'm not sure? Variable, of course, but how does it get called there? For now the model has 3 folders - 19.88, 22.88, 25.88 and I'm hoping the On Error Resume Next will get it through the missing folders.
Edit: Bonus points for anyone who can identify a way to dynamically add the folders in the design tree to the array and then link that array to the MultiValue.SetList linked to Compactor_Size. Would be super neat to have that flexibility so that when a new folder is created it pops up as an available size and the macro doesn't have to be edited
Edit Edit:
Turns out a quick way around this is to use the Select command to select multiple folders. Slightly less convenient than a for loop but considerably more convenient than alternatives
Solved! Go to Solution.