If you're not using inventor 2017 then there is a other way.
I've been struggling with the LOD for a long time and decided to make use of the visibility of parts.
Like you said, the BOM will not be influenced by the visibility of parts. Therefore I'm using the next Ilogic code.
It sets the parts that are invisible to reference in the BOM.
SyntaxEditor Code Snippet
Sub Main()
Question = MessageBox.Show("Wilt u de Bill Of Materials updaten? Dit kan enkele minuten duren.", "BOM",MessageBoxButtons.YesNo,MessageBoxIcon.Information)
If Question = vbYes Then
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
Call toggle(oOccurrence)
If oOccurrence.DefinitionDocumentType = kAssemblyDocumentObject Then
Call ListComp(oOccurrence)
End If
Next
End If
End Sub
Sub ListComp(oOcc As ComponentOccurrence)
Dim oOcc1 As ComponentOccurrence
For Each oOcc1 In oOcc.SubOccurrences
Call toggle(oOcc1 )
If oOcc1.DefinitionDocumentType = kAssemblyDocumentObject Then
Call ListComp(oOcc1)
End If
Next
End Sub
Sub toggle(oOcc As ComponentOccurrence)
If Not TypeOf oOcc.Definition Is VirtualComponentDefinition Then
If Component.Visible(oOcc.Name) = True Then
Component.InventorComponent(oOcc.Name).BOMStructure = _
BOMStructureEnum.kDefaultBOMStructure
ElseIf Component.Visible(oOcc.Name) = False Then
Component.InventorComponent(oOcc.Name).BOMStructure = _
BOMStructureEnum.kReferenceBOMStructure
End If
End If
End Sub
In my assembly it takes up to 3-4 minutes to walk through the whole model