Message 1 of 12
Rule hangs at oDef = oBOMRow.ComponentDefinitions.Item(1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello..
I have a rule that stumbles on:
oDef = oBOMRow.ComponentDefinitions.Item(1)
in a particular assembly.
While in another assembly there is no problem.
This in a Sub ProcessBOMRowsRecursively.
I'm using the Model Data BOMView.
On purpose to also have insight into Phantom assemblies.
It's in a certain document, it doesn't happen right away.
Before oDef is defined, how can I determine what kind of document it is and whether or not I want to go through it?
I mean in the case of a Content Center or Library part.
Any idea what that could be?
Could it be a suppressed part or assembly?
Btw should wat should it be?
oDef = oBOMRow.ComponentDefinitions(1)
oDef = oBOMRow.ComponentDefinitions.item(1)
The 841 where is goes wrong, thereafter where I call the BOMView:
Sub BOM_First_Loop_Get_ListsData_TotalQTY_LengthsData(oBOMRows As BOMRowsEnumerator, Optional SubQty As Integer = 1)
Dim oBOMRow As BOMRow
Logger.debug("Here in BOM_First_Loop_Get_ListsData_TotalQTY_LengthsData")
For Each oBOMRow In oBOMRows
'----------------------------------------------------------------------------------------------------
' Progress Bar, update the Message shown within the Progress Bar with each loop.
oProgressBar.Message = "Start Calculation " '& i & " Of " & oSteps_Progress_Bar
'----------------------------------------------------------------------------------------------------
' Let's only get the first definition
' It would only be more than one if rows were merged
Dim oDef As ComponentDefinition
'oDef = oBOMRow.ComponentDefinitions(1)
oDef = oBOMRow.ComponentDefinitions.Item(1)
Dim oDoc As Document = oBOMRow.ComponentDefinitions.Item(1).Document
Logger.debug("Here in BOM_First_Loop_Get_ListsData_TotalQTY_LengthsData" & vbNewLine & "oDoc: " & oDoc .FullFileName)
'----------------------------------------------------------------------------------------------------
' In case of unsaved items in the Main Assembly Exit the program
' Set boolForcedTerminated = True
' Because there is a chance that it will be noticed again and the program can act on it by closing
If oDoc.FullFileName = ""
'----------------------------------------------------------------------------------------------------
' Connect to the BOM to collect data
Dim oBOM As BOM
oBOM = oAsmDoc.ComponentDefinition.BOM
' Make sure it's enabled
oBOM.StructuredViewEnabled = True
oBOM.StructuredViewFirstLevelOnly = False
'oBOM.PartsOnlyViewEnabled = True
' Select BOM Type
Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews(1) 'Model Data
'oBOMView = oBOM.BOMViews("Structured")
'oBOMView = oBOM.BOMViews("Parts Only")
'----------------------------------------------------------------------------------------------------
' Renumber and sort the BOM
' Will that affect the output?
Try
oBOMView.Renumber(1, 1)
oBOMView.Sort2("Item")
Catch
' Sort will not work for Model Data BOM
End Try