Message 1 of 9
Sub-Assembly Quantity in List
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've got code that goes through an assembly and finds all of the documents with a certain property set. It then adds it to a list with the stock number, file path, and qty. The issue I'm running into is if there is a main assembly (Call it A) with multiple sub assemblies (Call it B) it will show the amount required for that sub assembly but if sub assembly B has another sub assembly (call it B.1) it doesn't multiply the quantity required just shows the total quantity required for one B assembly. It also doesn't account if sub C is in other sub assemblies. Below is a snippet of the code I have that
Private Function GetBOMstructure(ByVal oBOM As BOM) As BOMView
Dim sLanguageBOM, sSortItem As String
Select Case ThisApplication.LanguageCode
Case "en-US"
sLanguageBOM = "Structured"
Case Else
Return Nothing
End Select
If oBOM.StructuredViewEnabled = False Then oBOM.StructuredViewEnabled = True
If oBOM.StructuredViewFirstLevelOnly = True Then oBOM.StructuredViewFirstLevelOnly = False
Return oBOM.BOMViews.Item(sLanguageBOM)
End Function
Private Function GetListComponents(ByVal oBOMRows As BOMRowsEnumerator, ByRef oListComp As Object)
Dim oCompDef As ComponentDefinition
For Each oRow As BOMRow In oBOMRows
oCompDef = oRow.ComponentDefinitions.Item(1)
Dim oDoc As Document = oCompDef.Document
If oDoc.PropertySets.Item("Design Tracking Properties").Item("Cost Center").Value = "ACC" Then
Dim sStokNumb As String = oDoc.PropertySets.Item("Design Tracking Properties").Item("Stock Number").Value
'Dim folderpath As String = oDoc.PropertySets.Item("Design Tracking Properties").Item("Location").Value
Dim folderpath As String = oDoc.File.FullFileName
'defines backslash as the subdirectory separator
Dim strCharSep As String = System.IO.Path.DirectorySeparatorChar
'find the postion of the last backslash in the path
FNamePos = InStrRev(folderpath, "\", -1)
'get the file name with the file extension
Name = Right(folderpath, Len(folderpath) -FNamePos)
'get the path of the folder containing the file
Folder_Location = Left(folderpath, Len(folderpath) -Len(Name) -1)
'Sets export location for batch plot pdf location
Dim FilePath As String = "X:\7 - Design\0 - Batch Plot Drawings\" + Folder_Location.Substring(16)
Dim NewFilePath As String = FilePath + "\"
'i = MessageBox.Show("The Value you entered was incorrect " & NewFilePath, "My iLogic Dialog", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
'Used if folder isn't in right location
Else
oListComp(sStokNumb + NewFilePath) = oListComp(sStokNumb + NewFilePath) + oRow.ItemQuantity
End If
If oRow.ChildRows IsNot Nothing Then
GetListComponents(oRow.ChildRows, oListComp)
End If
Next
End Function