Hi Mohan,
I have updated the iLogic rule to cover the assembly, which has the multiple levels of sub-assembly. Please see the code lines below –
Sub Main()
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
If oOccurrence.DefinitionDocumentType = kPartDocumentObject Then
If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then
If Component.Visible(oOccurrence.Name) = True Then
Component.InventorComponent(oOccurrence.Name).BOMStructure = _
BOMStructureEnum.kDefaultBOMStructure
ElseIf Component.Visible(oOccurrence.Name) = False Then
Component.InventorComponent(oOccurrence.Name).BOMStructure = _
BOMStructureEnum.kReferenceBOMStructure
End If
End If
ElseIf oOccurrence.DefinitionDocumentType = kAssemblyDocumentObject Then
Call ListComp(oOccurrence)
End If
Next
End Sub
Function ListComp(oOcc As ComponentOccurrence)
Dim oOcc1 As ComponentOccurrence
For Each oOcc1 In oOcc.SubOccurrences
If oOcc1.DefinitionDocumentType = kPartDocumentObject Then
If Not TypeOf oOcc1.Definition Is VirtualComponentDefinition Then
If Component.Visible(oOcc1.Name) = True Then
Component.InventorComponent(oOcc1.Name).BOMStructure = _
BOMStructureEnum.kDefaultBOMStructure
ElseIf Component.Visible(oOcc1.Name) = False Then
Component.InventorComponent(oOcc1.Name).BOMStructure = _
BOMStructureEnum.kReferenceBOMStructure
End If
End If
ElseIf oOcc1.DefinitionDocumentType = kAssemblyDocumentObject Then
Call ListComp(oOcc1)
End If
Next
End Function
Thanks,
River Cai
Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com