Message 1 of 9
Change BOMStructure to subassembly when the BOMStructure of assembly is Purchased
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everybody! I'm trying to write a macro in order to change BOMStructure of all subcomponents when the BOMStructure of assembly parent is "purchased"
I mean:
1 Assembly --> BOMStructure=Purchased
1.1 Component 1 --> BOMStructure=Normal (change to "purchased")
1.1.2 Component 1 --> BOMStructure=Normal (change to "purchased")
I found some macro codes which allow transverse through the subassemblies of an assembly, but I'm not able to change the BOMStructure of subassemblies. Any suggestion how could I manage it?
This is the code I've recently found in this forum:
Public Sub Main() ' Get the active assembly. Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument Call TraverseAssembly(oAsmDoc.ComponentDefinition.Occurrences, 1) End Sub Private Sub TraverseAssembly(Occurrences As ComponentOccurrences, _ Level As Integer) Dim oOcc As ComponentOccurrence For Each oOcc In Occurrences Try oOcc.Definition.BOMStructure = BOMStructureEnum.kPhantomBOMStructure Catch 'MsgBox(oOcc.Name & "remains unchanged") End Try ' Check to see if this occurrence represents a subassembly ' and recursively call this function to traverse through it. If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then Call TraverseAssembly(oOcc.SubOccurrences, Level + 1) End If Next End Sub