Getting List of Items in Named Model Tree Folder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Looking for some help with an iLogic script I'm trying to write to create a list of ship loose items - first part that's commented out is looking for an iProperty on parts/assemblies which works, but the second part is what's giving me headaches. The reason I need the second part is for things like fasteners that we use in multiple places where the iProperty shouldn't be assigned, so for that case I figured it was easier to dump items into a folder in the model tree. I can get to the folder using the below code but trying to figure out what's in the folder has me stumped... Checked the iLogic documents and BrowserNode is supposed to be able to get contents of a folder however nothing in there seems to suggest it can get the items in the folder.
Dim oDoc As Document = ThisDoc.Document
Dim refDoc As Document
Dim shiplooseItems As New System.Text.StringBuilder()
Dim shipMethod, refDocPN As String
'Logger.Info("")
' this successfully finds the iProperty ShippingMethod and determines if it is loose or not
'For Each refDoc In oDoc.AllReferencedDocuments
' Dim custPropSet As PropertySet
' Dim pnPropSet As PropertySet
' custPropSet = refDoc.PropertySets.Item("Inventor User Defined Properties")
' pnPropSet = refDoc.PropertySets.Item("Design Tracking Properties")
' Try :
' shipMethod = custPropSet.Item("ShippingMethod").Value
' If shipMethod = "Loose" Then
' refDocPN = pnPropSet("Part Number").Value
' Logger.Info(refDocPN & " is ship loose")
' End If
' Catch :
' GoTo Skip :
' End Try
' Skip :
'Next
For Each refDoc In oDoc.AllReferencedDocuments
If refDoc.DocumentType = kAssemblyDocumentObject Then
Dim oPane As BrowserPane = refDoc.BrowserPanes.Item("Model")
Dim oTargetNode As BrowserNode = oPane.TopNode
Dim folderName As String
If oTargetNode.BrowserFolders.Count > 0 Then
For Each xFolder In oTargetNode.BrowserFolders
folderName = xFolder.Name
If InStr(folderName, "oose") > 0 Then
' get item names and qty inside xFolder
Dim oFolder As BrowserFolder = oTargetNode.BrowserFolders.Item(folderName)
Logger.Info(refDoc.DisplayName & ": " & xFolder.Name) ' correctly finds folder
'Next
End If
Next
End If
End If
Next