Adding file to a browser folder

Adding file to a browser folder

MattH_Work
Collaborator Collaborator
1,597 Views
3 Replies
Message 1 of 4

Adding file to a browser folder

MattH_Work
Collaborator
Collaborator

I'm using the following sample code to add files to a browser folder

 

Public Sub AddOccurrencesToFolder()

    Dim oDoc As AssemblyDocument     Set oDoc = ThisApplication.ActiveDocument

    Dim oDef As AssemblyComponentDefinition     Set oDef = oDoc.ComponentDefinition

    Dim oPane As BrowserPane     Set oPane = oDoc.BrowserPanes.ActivePane

    Dim oOccurrenceNodes As ObjectCollection     Set oOccurrenceNodes = ThisApplication.TransientObjects.CreateObjectCollection

    Dim oOcc As ComponentOccurrence     For Each oOcc In oDef.Occurrences

        Dim oNode As BrowserNode         Set oNode = oPane.GetBrowserNodeFromObject(oOcc)

        oOccurrenceNodes.Add oNode     Next

    Dim oFolder As BrowserFolder     Set oFolder = oPane.AddBrowserFolder("My Occurrence Folder", oOccurrenceNodes)

End Sub

 

How do I get the files added to an existing " My Occurrence Folder" rather than creating a new one. Every time I run the code a new folder is created, it does not use the exisitng one

 

cheers

 

Matt


MattH
Product Design Collection 2026
Vault Pro 2026
0 Likes
1,598 Views
3 Replies
Replies (3)
Message 2 of 4

philippe.leefsma
Alumni
Alumni

Hi Matt,

 

How about using "BrowserFolder.Add" Method.

 

You should be able to retrieve an existing BrowserFolder by parsing the browser nodes and use "BrowserNode.BrowserFolders" property to acess it.

 

Please refer to the Help Files for more details about those APIs.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi Philippe,

Can you please post an example iLogic code using the "BrowserFolder.Add" method? I am using iLogic to place components then move then to a folder, and I can't figure out how to add component occurrences to a specific folder.

 

Thanks,

Paul

0 Likes
Message 4 of 4

Jef_E
Collaborator
Collaborator

I know this is an old topic, but I was searching for this solution and it was lacking the requested sample.

 

Here is the sample that works for me. I hope someone else can also benefit from this "late" response.

 

' get the model browser pane
Dim oPane As BrowserPane
oPane = oAssemblyDoc.BrowserPanes.Item("Model")

' Create a Browser node object from an existing object
Dim oNode As BrowserNode
oNode = oPane.GetBrowserNodeFromObject(oOccurrence)

' Add the node to the extra folder
oPane.TopNode.BrowserFolders.Item("Extra").Add(oNode)


Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2