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: 

Adding file to a browser folder

3 REPLIES 3
Reply
Message 1 of 4
MattH_Work
1352 Views, 3 Replies

Adding file to a browser folder

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 2025
Vault Pro 2025
3 REPLIES 3
Message 2 of 4

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

Message 3 of 4

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

Message 4 of 4
Jef_E
in reply to: freudeind

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

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

Post to forums  

Autodesk Design & Make Report