Supressing folders - slight variation - Manufacturing DevBlog

Supressing folders - slight variation - Manufacturing DevBlog

andrew_canfield
Collaborator Collaborator
410 Views
3 Replies
Message 1 of 4

Supressing folders - slight variation - Manufacturing DevBlog

andrew_canfield
Collaborator
Collaborator

I've used this code:

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

 

Which will supress top level folders but not he lower lever ones - reading the code am i misunderstanding 

' Recursive function as there could be subfolders too

Thinking these are lower sub assembly folders?

ref.JPG

 

Sorry to keep going on about this - just feel the end is so close!

 

Regards

 

Andrew

0 Likes
Accepted solutions (1)
411 Views
3 Replies
Replies (3)
Message 2 of 4

JamieVJohnson2
Collaborator
Collaborator

Recursive functions call themselves, but when and how is what matters.  Example:

 

Function CrawlTree (tn as TreeNode) as list(of nodes)

dim listNodes as new list(of TreeNode)

'look for children items

for each subNode as TreeNode in tn.Nodes

      listnodes.add(subNode)

'check to see if children have children of their own

    if subNode.Nodes.count > 0 then

'here is the recursion, calling itself until then sub node count is 0

     listNodes.addrange(CrawlTree(subNode))

next

return listNodes

End Function

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 3 of 4

andrew_canfield
Collaborator
Collaborator

I've found this which will name each part within an assembly (but would like it to name each folder).

    ' Get the active assembly. 
    Dim oAsmDoc As AssemblyDocument 
     oAsmDoc = ThisApplication.ActiveDocument 

    ' Get the assembly component definition. 
    Dim oAsmDef As AssemblyComponentDefinition 
     oAsmDef = oAsmDoc.ComponentDefinition 

    ' Get all of the leaf occurrences of the assembly. 
    Dim oLeafOccs As ComponentOccurrencesEnumerator 
     oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences 

    ' Iterate through the occurrences and print the name. 
    Dim oOcc As ComponentOccurrence 
    For Each oOcc In oLeafOccs 
        xx = oOcc.Name 
		MessageBox.Show(xx, "Title")

    Next 

Also this which will supress  a folder (but only the top level )

oPane = ThisDoc.Document.BrowserPanes.Item("Model")
oFolder = oPane.TopNode.BrowserFolders.Item("Ref")
oFolderNodes = oFolder.BrowserNode.BrowserNodes

For Each oNode As BrowserNode In oFolderNodes
	oComp = oNode.NativeObject
	oComp.Suppress
Next

Trying to merge the two bits of code - not sure if 'TopNode' means just the top of the browser?

 

folder.JPG

 

https://forums.autodesk.com/t5/inventor-customization/suppressing-folders-using-ilogic-not-updating-...

 

https://modthemachine.typepad.com/my_weblog/2009/03/accessing-assembly-components.html

 

folder nodes.JPG

 

Would like to find all folders named 'Ref' within the assembly tree.

 

Regards

 

Andrew

0 Likes