iLogic control browser folders

iLogic control browser folders

drichter
Contributor Contributor
3,770 Views
17 Replies
Message 1 of 18

iLogic control browser folders

drichter
Contributor
Contributor

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

0 Likes
3,771 Views
17 Replies
Replies (17)
Message 2 of 18

xiaodong_liang
Autodesk Support
Autodesk Support
Hi,

the corresponding API object for browser folder is "BrowserFolder", but it has only Delete method. No "Activate"/ "Suppress" method. you will have to filter out the components and suppress them one by on. Sorry.
0 Likes
Message 3 of 18

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

I saw 

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 

 

 

 

 

 

0 Likes
Message 4 of 18

drichter
Contributor
Contributor

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

0 Likes
Message 5 of 18

xiaodong_liang
Autodesk Support
Autodesk Support

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

http://forums.autodesk.com/t5/Inventor-General/iLogic-Questions-Wildcards-assy-folders-amp-pushing-p...

0 Likes
Message 6 of 18

Anonymous
Not applicable

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)

 

Message 7 of 18

drichter
Contributor
Contributor

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

0 Likes
Message 8 of 18

dfitting
Contributor
Contributor

Is it possible to change the visibility of the parts in the folder rather than suppress them?

0 Likes
Message 9 of 18

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

This should do what you need:

oComp.Visible = False

 

Cheers,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 10 of 18

Anonymous
Not applicable

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

0 Likes
Message 11 of 18

drichter
Contributor
Contributor
Haven't figured out suppressing a pattern in the folder and it would be helpful with a lot of the hardware. I saw you have the question out there, did you get any responses? I can suppress the pattern when it's outside the folder but needs extra code and more lines in the browser. Would be so much cleaner if we could put it in a folder.

Let me know if you get anywhere with it and I'll update this post if I come up with something.
0 Likes
Message 12 of 18

Anonymous
Not applicable

No, unfortunately no one has commented on the issue , untill now

 Man Sad

0 Likes
Message 13 of 18

adam.nagy
Autodesk Support
Autodesk Support

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

 http://adndevblog.typepad.com/manufacturing/2012/05/how-can-i-suppress-the-circular-pattern-componen...

 

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,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 14 of 18

Anonymous
Not applicable

Hi,

Thanks for for Your code but what I was looking for is a way to suppress a folder containing pattern and parts

0 Likes
Message 15 of 18

adam.nagy
Autodesk Support
Autodesk Support

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?



Adam Nagy
Autodesk Platform Services
0 Likes
Message 16 of 18

Anonymous
Not applicable

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

 

 

 

0 Likes
Message 17 of 18

adam.nagy
Autodesk Support
Autodesk Support

I think this should cover everything:

http://adndevblog.typepad.com/manufacturing/2015/05/suppress-folder-in-assembly.html



Adam Nagy
Autodesk Platform Services
0 Likes
Message 18 of 18

JimmyDoe
Collaborator
Collaborator

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?

iLogic error.png

 

 

0 Likes