Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
filippo.toniello
486 Views, 4 Replies

Assembly Model tree Reorder fail for specifc Folder

Hi everyoone

I searched through the forum but i did not find any related info.

I adapted an existing ilogic code to find all screws, bolt, nuts and washer from content center and  moving to a folder in the browser tree. It works like a charm but i would also move this folder under the "origin" folder.

I used the reorder method but i encounter a unspecified error. Someone can helpme?

here the error

2021-03-05 10_13_31-Autodesk Inventor Professional 2020.png

 

 

'define folder name to use
sFolder = "VITERIE"

'define assembly doc
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

'define assembly Component Definition
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oDoc.ComponentDefinition

'get browser pane
Dim oPane As BrowserPane 
oPane = oDoc.BrowserPanes.ActivePane


'try to get existing folder by name and delete it
'catch error if not found
Dim oFolder As BrowserFolder 
Try
	oFolder = oPane.TopNode.BrowserFolders(sFolder)
	oFolder.Delete
Catch	
End Try

Dim oCollection As ObjectCollection
oCollection = ThisApplication.TransientObjects.CreateObjectCollection

'Iterate through all of the occurrences in the assembly
Dim oOcc As ComponentOccurrence
For Each oOcc In oAsmCompDef.Occurrences
	'look at only virtual components
	If oOcc.DefinitionDocumentType=kPartDocumentObject Then
		If oOcc.Definition.IsContentMember Then
			Dim Opartdef As PartcomponentDefinition
			Opartdef = oOcc.Definition
			Dim oObjPart As PartDocument
			oObjPart = Opartdef.Document
			Dim invDesignInfo As PropertySet
			invDesignInfo = oObjPart.PropertySets.Item("Design Tracking Properties")
			
			If Left(invDesignInfo.Item("Description").Value,3) = "VIT" Or Left(invDesignInfo.Item("Description").Value,3) = "DAD" Or Left(invDesignInfo.Item("Description").Value,3) = "ROS" Or Left(invDesignInfo.Item("Description").Value,3) = "RON" Then
			
				'get browser node of occurence
				Dim oNode As BrowserNode
				oNode = oPane.GetBrowserNodeFromObject(oOcc)
				'add node to collection
				oCollection.Add(oNode)
			
			End If	
		End If
	End If	
Next
' recreate folder
'And add collection To folder
 
oFolder = oPane.AddBrowserFolder(sFolder,oCollection)
Dim oNNode As BrowserNode
	oNNode = oFolder.BrowserNode

Dim oDocNode As BrowserNode
oDocNode = oPane.TopNode
Dim oPosNode As BrowserNode

Dim oInizNode As BrowserNode
For Each oInizNode In oDocNode.BrowserNodes	
	If oInizNode.FullPath.Contains("Origine") Then
	oPosNode = oInizNode
		End IF
Next


' ' Move the folders to upper of oFirstOccurrenceNode
oPane.Reorder(oPosNode,False,oNNode)
   

 

 

Hello

 

You can not place your folder below the origin node. As in the GUI the highest position is below end of part.


R. Krieg
RKW Solutions
www.rkw-solutions.com

ok thakns for the reply.

But in the GUI i can do this (please see pict below)

 

2021-03-06 11_21_36-Autodesk Inventor Professional 2020.png

 

is it possible to do the same with ilogic?

Hello

 

No, there are BrowserNodes between, but they are invisible. Between your folder and the origin are at least the Positional Representation and the End of Element Nodes. I use a localized german version, so I can't tell you the right name of the nodes. You can check this with this little iLogic Script

Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oDoc.ComponentDefinition

Dim oPane As BrowserPane 
oPane = oDoc.BrowserPanes.ActivePane

Dim oDocNode As BrowserNode
oDocNode = oPane.TopNode

Dim oNode As BrowserNode
Dim bVisible As Boolean 

For Each oNode In oDocNode.BrowserNodes 
	bVisible=oNode.Visible.ToString 
	MsgBox("Name: " & oNode.BrowserNodeDefinition.Label & vbCrLf & "Visible: " & bVisible, , "NodeNames")
Next

 

 


R. Krieg
RKW Solutions
www.rkw-solutions.com

Danke krieg it helps a lot