Working on a product configurator using iLogic and have a large amount of hardware that needs to be suppress or unsuppressed based on certain parameter choices. Instead of creating hundreds of lines of code suppressing and unsuppressing the hardware one by one, I was hoping to put hardware into folders based configurations. In my mind this would have allowed me to have one line that would suppress the folder as needed. Unfortunately I cannot figure how to suppress a folder in iLogic as I saw someone else mention I was hoping for a "Folder.IsActive" rule but have yet to find one. Any help someone could offer would be greatly appreciated.
Inventor 2013
Hi,
I saw jdkriek shared a very smart workaround which he has posted in the other thread,
http://forums.autodesk.com/t5/Inventor-Customization/Supress-entire-folder-How/td-p/3588018
but it looks he removed his comment in this thread.I do not know why, however the workaround is cool to me.So I converted it to iLogic code. Hope it helps.
Thanks jdkriek!
doc = ThisDoc.Document Dim folder As BrowserFolder 'assume one folder has been selected. Try folder = doc.SelectSet.Item(1) MsgBox (folder.Name & " is selected.") 'get the built-in command of Inventor ' which suppress the whole folder Dim oCommandMgr As CommandManager oCommandMgr = ThisApplication.CommandManager 'Toggle suppress or unsuppress oCommandMgr.ControlDefinitions.Item("AssemblyCompSuppressionCtxCmd").Execute2(True) Catch MsgBox ("Select a browser folder") End Try
The code works well as you have written it. I am struggling with modifying how to select a specific folder based on a parameter choice. I was hoping to modify the "folder = doc.SelectSet.Item(1)" line of the code to have it select a specific folder but with no luck
For example if a multivalue parameter has 2 choices (red or blue) and I have 2 folders in my browser (old and new).
If color = "red" then folder "old" is active and "new" is supressed
If color = "blue" then folder "old" is suppressed and "new" is active
Thanks
folder = doc.SelectSet.Item(1) assumes the folder HAS been selected.
To get a specific folder by code, you need to use relevant objects of BrowserNode & BrowserPane.
Please refer to this link where you can know how to get a folder by name, and also other useful information of BrowserNode & BrowserPane
Here is what I use:
' supressing folder oApp = ThisApplication oDoc = oApp.ActiveDocument oPane = oDoc.BrowserPanes("Model") oTopNode = oPane.TopNode 'Define which folder to suppress folder = oTopNode.BrowserFolders.Item(FolderName) oSelectSet = oDoc.SelectSet oSelectSet.Clear 'Select the folder automatically oSelectSet.Select(folder) 'MsgBox ("The folder """ & folder.Name & """ is selected.") Dim oCommandMgr As CommandManager oCommandMgr = oApp.CommandManager 'Toggle suppress or unsuppress oCommandMgr.ControlDefinitions.Item("AssemblyCompSuppressionCtxCmd").Execute2(True)
The code below is what I ended up with. Based on a choice of color it will suppress one folder and unsuppressed another.
'Get the normal assembly browser pane object
oPane = ThisDoc.Document.BrowserPanes.Item("Model")
If Color = "Red" Then
oFolder = oPane.TopNode.BrowserFolders.Item("NewFolder") 'Get the browser folder object
oFolderNodes = oFolder.BrowserNode.BrowserNodes 'Get the set of nodes in the folder
For Each oNode As BrowserNode In oFolderNodes 'Cycle through each browser node in the folder
oComp = oNode.NativeObject
oComp.Suppress
Next
oFolder = oPane.TopNode.BrowserFolders.Item("OldFolder") 'Get the browser folder object
oFolderNodes = oFolder.BrowserNode.BrowserNodes 'Get the set of nodes in the folder
For Each oNode As BrowserNode In oFolderNodes 'Cycle through each browser node in the folder
oComp = oNode.NativeObject
oComp.Unsuppress
Next
ElseIf Color = "Blue" Then
oFolder = oPane.TopNode.BrowserFolders.Item("NewFolder") 'Get the browser folder object
oFolderNodes = oFolder.BrowserNode.BrowserNodes 'Get the set of nodes in the folder
For Each oNode As BrowserNode In oFolderNodes 'Cycle through each browser node in the folder
oComp = oNode.NativeObject
oComp.Unsuppress
Next
oFolder = oPane.TopNode.BrowserFolders.Item("OldFolder") 'Get the browser folder object
oFolderNodes = oFolder.BrowserNode.BrowserNodes 'Get the set of nodes in the folder
For Each oNode As BrowserNode In oFolderNodes 'Cycle through each browser node in the folder
oComp = oNode.NativeObject
oComp.Suppress
Next
End If
Hi drichter
Nice rule You made , thanks.
I am using it , but also need to suppress a folder with a pattern in?
Have You cracked that?
Thanks
Hi,
In order to suppress elements of a pattern you just have to iterate through the components of each element and suppress those (oOccPatElement.Occurrences):
Dim oOccPatElement As _ OccurrencePatternElement For Each oOccPatElement In _ oOccPattern. _ OccurrencePatternElements Dim oCompOcc As ComponentOccurrence For Each oCompOcc In _ oOccPatElement.Occurrences oCompOcc.Visible = False Next Next oOccPatElement
The above code makes them invisible, but suppressing them is the same, just a different function.
Also, I hope you are aware that you can test things in VBA as well, because that's just way more simple and there you can check properties, step thorugh code, etc:
http://adndevblog.typepad.com/manufacturing/2013/10/discover-object-model.html
Cheers,
Hi,
Thanks for for Your code but what I was looking for is a way to suppress a folder containing pattern and parts
My understanding is that when you click on a folder to suppress it, then Inventor will go through all the components in it and suppress them.
Do you find a difference in the behaviour when you suppress all components inside a folder one by one yourself, or through the folder's suppress button?
To clearify what I am looking for ,is a rule where I can suppress the folder A containing a pattern and parts :
Folder A:
Pattern 1
Part 2
Part 3
I think this should cover everything:
http://adndevblog.typepad.com/manufacturing/2015/05/suppress-folder-in-assembly.html
Hi,
I am also using drichter's code, but I am using it to control the suppression/unsuppression of multiple folders. I have five different configurations that I would like to be controlled by one parameter. I copied the code and modified it to include my folders.
I am now getting the error: Operator '=' is not defined for 'Nothing' and type 'BrowserFolder'. Can someone shed some light on this, for me?