Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic control browser folders

17 REPLIES 17
Reply
Message 1 of 18
drichter
3294 Views, 17 Replies

iLogic control browser folders

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

17 REPLIES 17
Message 2 of 18
xiaodong_liang
in reply to: drichter

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.
Message 3 of 18
xiaodong_liang
in reply to: drichter

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 

 

 

 

 

 

Message 4 of 18
drichter
in reply to: xiaodong_liang

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

Message 5 of 18
xiaodong_liang
in reply to: drichter

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...

Message 6 of 18
achmidt
in reply to: drichter

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)

 

Inventor Virtual Parts Addin

http://apps.exchange.autodesk.com/INVNTOR/en/Detail/Index?id=appstore.exchange.autodesk.com%3Avirtualpartsadd-in_windows32and64%3Aen
Message 7 of 18
drichter
in reply to: achmidt

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

Message 8 of 18
dfitting
in reply to: drichter

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

Message 9 of 18
adam.nagy
in reply to: dfitting

Hi,

 

This should do what you need:

oComp.Visible = False

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 10 of 18
Agenx
in reply to: drichter

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

Message 11 of 18
drichter
in reply to: Agenx

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.
Message 12 of 18
Agenx
in reply to: drichter

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

 Man Sad

Message 13 of 18
adam.nagy
in reply to: Agenx

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
Message 14 of 18
Agenx
in reply to: adam.nagy

Hi,

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

Message 15 of 18
adam.nagy
in reply to: Agenx

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
Message 16 of 18
Agenx
in reply to: adam.nagy

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

 

 

 

Message 17 of 18
adam.nagy
in reply to: Agenx

I think this should cover everything:

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



Adam Nagy
Autodesk Platform Services
Message 18 of 18
JimmyDoe
in reply to: adam.nagy

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

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report