How to move a part into an existing folder in an assembly?

How to move a part into an existing folder in an assembly?

patrick.r.cantwell
Explorer Explorer
3,953 Views
5 Replies
Message 1 of 6

How to move a part into an existing folder in an assembly?

patrick.r.cantwell
Explorer
Explorer

I have an assembly in Inventor with about 3500 parts. I'm trying to organize these parts into folders.

 

The way I've figured out to move a part into an existing folder is to left-click the part in the hierarchy and then to drag it into the folder. This works fine, but it's very slow when clicking & dragging a part past several thousand other parts in the hierarchy to move it into the folder.

 

Are there any other ways to move a part into an existing folder besides clicking & dragging?

 

In case it helps to answer my question, I've attached a screenshot of the assembly hierarchy.  It contains a folder I made called "MyFolder", which has two parts in it.  When I right-click on other parts in the hierarchy, e.g. Solid3:1 in this screenshot, I don't see any options for moving the part directly into "MyFolder".  I can only click & drag it into "MyFolder" (or add it to a new folder). 

 

I also tried clicking & dragging parts from the viewport into "MyFolder" but that didn't work.  And right-clicking on parts in the viewport doesn't give any obvious options for moving them to an existing folder, although I can add them to a new folder by doing that.

 

This assembly originated as a STEP file with approximately 3500 separate solid bodies.  I imported the STEP file into Inventor and then converted it to an assembly.

 

I'm new to Inventor so I might be missing something obvious... any help would be appreciated.

0 Likes
Accepted solutions (1)
3,954 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor
Accepted solution

You could just window on screen to select the parts,  click on selected browser node and right click and add to new folder, move folder into my folder. Then delete any folder you don't need. The parts will simply move up the hierarchy inside the folder. 

 

Here is an ilogic method to add directly to a folder. You can select the folder or create a new folder then select multiple items at a time then press Esc to exit and add the parts to the folder. Code source examples selection of multiple occurrences and here for the Moving browser nodes to a folder. Try it out on a test assembly and ensure it works as you need.

 

EDIT: Remove original rule posted as it was not working as expected and also was creating duplicate folders.

 

Working rule.  

Dim oFolderName As String
obj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Select a Folder, Press Esc when selected or to create a folder") 
Dim oFolder As BrowserFolder
If TypeOf obj Is Inventor.BrowserFolder Then 'Check a folder object was selected
	oFolderName = obj.Name
Else
	oFolderName = InputBox("Enter Name", "Folder Name", "My Folder")
	If oFolderName = "" Then Return
End If
	
'[Selecting Component
Dim comps As ObjectCollection
Dim comp As Object

comps = ThisApplication.TransientObjects.CreateObjectCollection

While True
	comp = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter,"Select a component to add to the folder, Press Esc when Complete") 	
	' If nothing gets selected then we're done	
	If IsNothing(comp) Then Exit While
	
	comps.Add(comp) 
End While
']

Dim oDoc As AssemblyDocument
 oDoc = ThisApplication.ActiveDocument

Dim oDef As AssemblyComponentDefinition
 oDef = oDoc.ComponentDefinition

Dim oPane As BrowserPane
 oPane = oDoc.BrowserPanes.ActivePane
 
Dim oOccurrenceNodes As ObjectCollection
 oOccurrenceNodes = ThisApplication.TransientObjects.CreateObjectCollection


Try 
oFolder = oPane.TopNode.BrowserFolders.Item(oFolderName)'Get reference to folder object
Dim oFolderBrowserNodes As BrowserNodesEnumerator
oFolderBrowserNodes = oFolder.BrowserNode.BrowserNodes
For Each oNode As BrowserNode In oFolderBrowserNodes 'cycle through contents of the folder
	comp = oNode.NativeObject 'Get occurrence object
	comps.Add(comp) ' add occurrence object to occurrence collection
Next
oFolder.Delete 'Delete folder to remove duplicate from being added later
Catch
End Try

For Each comp In comps 'Cycle Through occurrence collection
    Dim oNode As BrowserNode
    oNode = oPane.GetBrowserNodeFromObject(comp) 
	oOccurrenceNodes.Add(oNode)
Next
	 
oPane.AddBrowserFolder(oFolderName, oOccurrenceNodes)'Add Folder and OccurrenceNodes

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 6

Gabriel_Watson
Mentor
Mentor

I think only through iLogic, unfortunately:
https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/adding-file-to-a-browser-folder/td-p/35...

https://go.d3tech.net/inventor-blog/inventor-tips-and-tricks-using-ilogic-to-automatically-place-com...


But your idea of right-click and having some sort of "select folder" submenu option is a good hint for the UI devs. I think it is worth pushing that more in the Inventor Ideas page, since it looks like it's been 5 years Chris Fritsche has posted it there:
https://forums.autodesk.com/t5/inventor-ideas/what-we-need-is-a-way-to-quot-add-selected-components-...

Message 4 of 6

patrick.r.cantwell
Explorer
Explorer

Thank you both for the helpful answers.  I had to watch a couple of Autodesk University courses on iLogic to understand how it works, which is the reason for my delayed response.

 

A. Acheson's methods both work and are much faster than what I was doing before.  I'll summarize the steps for others who might be interested:

 

Method #1 (add parts to new folder, move new folder into existing folder, delete new folder):  

  1. Select the part(s) you want to add to the existing folder
  2. Right-click and select "Add to New Folder"
  3. Drag & drop this new folder into the existing folder
  4. Then, right-click on the new folder and delete it.  Only the folder will be deleted.  The parts that were in it will be contained in the existing folder.

 

Method #2 (iLogic)

a) Setting up the iLogic:

  1. Click the + button next to the Model tab and select iLogic
  2. In the iLogic tab, right-click in the blank area and select Add Rule
  3. Give the new rule a good name (e.g., "Add Parts to Existing Folder")
  4. In the Edit Rule dialog box, copy & paste A. Acheson's iLogic code into the code area
  5. Click "Save" and "Close"

b) Running the iLogic rule (do this every time you want to add more parts to an existing folder):

  1. In the iLogic tab, right-click the rule and select Run Rule
  2. In the Model tab, click on the existing folder you want to add parts to (the tool tip by the cursor tells you to do this; if you don't click a folder it will prompt you for it)
  3. Then, in either the Model tab or the Viewport, click all the parts you want to add to the folder (the tool tip by the cursor tells you do to this).  You don't need to shift-select the parts.  Any parts you click will be added.
  4. Press the Esc key when you finish selecting parts.  They will be added to the folder you chose.

 

I might eventually try writing a plug-in to get a right-click option to add parts directly to an existing folder, since it would be even faster than these two solutions (fewer clicks).  But these two methods are probably good enough for now.

 

Thanks again for your help.

Message 5 of 6

A.Acheson
Mentor
Mentor

Nice instructions you have there. I finished off a more usable ilogic rule and posted it in the ideas post here.   @Gabriel_Watson kindly located this post earlier for us to vote up. As you have suggested typing in a folder name each time is a workable solution but not optimal, less typing and more action is what I like to see. The rule  allows you to window select the components before you run the rule or to pick each one separately after the rule starts and also you have the option of selecting an existing folder or if you like create a new one. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 6 of 6

patrick.r.cantwell
Explorer
Explorer

Thanks for the updated rule.  I like that the components can be selected before selecting the folder.  I didn't notice that before.

 

I also found that the iLogic panel can be popped out, so there is no need to tab back and forth between the iLogic and Model panels when adding parts to folders (fewer mouse clicks).

 

 

0 Likes