Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello. I'm trying to write a code that gives me the number of each specific part in my assembly.
The obvious answer is to look at the BOM, but I want it to use the reference documents like the rest of my code.
This is kind of what I want, but it gives the total number of parts in the assembly.
' Get the active assembly. Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisDrawing.ModelDocument ' Get the assembly component definition. Dim oAsmDef As AssemblyComponentDefinition oAsmDef = oAsmDoc.ComponentDefinition ' Get all of the leaf occurrences of the assembly. Dim oLeafOccs As ComponentOccurrencesEnumerator oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences ' Iterate through the occurrences and print the name. Dim cnt As Integer cnt = 0 Dim oOcc As ComponentOccurrence For Each oOcc In oLeafOccs If oOcc.BOMStructure = BOMStructureEnum.kNormalBOMStructure Then cnt = cnt + 1 MessageBox.Show(oOcc.Name) End If Next MessageBox.Show(cnt)
Solved! Go to Solution.