Is there a way to have a column in the parts list that shows the purchased parts?
I want the info from the BOM called BOM Structure to show in the parts list.
Pretty sure the answer is no (as it should be).. BUT you can do a parts list filter and have it only show purchased parts.
Do you not have an ERP system? You should. Purchasing based off a drawing is just silly.
You can also just export the BOM and get that information.
Hello,
Mcgyvr is right and using a part list filter is a good solution.
We can also scan the assembly and set a custom Iproperty that writes the BOM Structure from structured BOM.
You can copy this piece of code in your ILogic, and use Itrigger tu run this rule each time you save for example.
This rule will scan your assembly and subassemblies, use the structured BOM Value and implement this value in a custom Iproperty in the file. You can display this custom Iprop in your parts list afterwards.
The code
Option Explicit
Sub Main Correct_G_L_parameter()
' Set reference to active document.
' This assumes the active document is an assembly
Dim odoc As Inventor.AssemblyDocument
odoc = ThisApplication.ActiveDocument
' Get assembly component definition
Dim oCompDef As Inventor.ComponentDefinition
oCompDef = odoc.ComponentDefinition
Dim sMsg As String
Dim iLeafNodes As Long
Dim iSubAssemblies As Long
' Get all occurrences from component definition for Assembly document
Dim oCompOcc As ComponentOccurrence
For Each oCompOcc In oCompDef.Occurrences
' Check if it's child occurrence (leaf node)
If oCompOcc.SubOccurrences.Count = 0 Then
iLeafNodes = iLeafNodes + 1
Call Assign_BOM(oCompOcc)
Else
iSubAssemblies = iSubAssemblies + 1
Call processAllSubOcc(oCompOcc, _
sMsg, _
iLeafNodes, _
iSubAssemblies) ' subassembly
End If
Next
odoc.Update
'Save the assembly
'odoc.Save
End Sub
' This function is called for processing sub assembly. It is called recursively
' to iterate through the entire assembly tree.
Private Sub processAllSubOcc(ByVal oCompOcc As ComponentOccurrence, _
ByRef sMsg As String, _
ByRef iLeafNodes As Long, _
ByRef iSubAssemblies As Long)
Dim oSubCompOcc As ComponentOccurrence
For Each oSubCompOcc In oCompOcc.SubOccurrences
' Check if it's child occurrence (leaf node)
If oSubCompOcc.SubOccurrences.Count = 0 Then
iLeafNodes = iLeafNodes + 1
Call Assign_BOM(oSubCompOcc)
Else
sMsg = sMsg + oSubCompOcc.Name + vbCr
iSubAssemblies = iSubAssemblies + 1
Call processAllSubOcc(oSubCompOcc, _
sMsg, _
iLeafNodes, _
iSubAssemblies)
End If
Next
End Sub
Private Sub Assign_BOM(ByRef oCompOcc As ComponentOccurrence)
Dim Bomstructure As String
Dim odoc As Object
Dim oPropSets As PropertySets
Dim opropset As PropertySet
Dim oUserPropertySet As PropertySet
Dim i As Integer
odoc = oCompOcc.Definition
oPropSets = odoc.Document.PropertySets
Select Case odoc.Document.ComponentDefinition.BOMStructure
Case 51969
Bomstructure = "Default"
Case 51970
Bomstructure = "Normal"
Case 51971
Bomstructure = "Phantom"
Case 51972
Bomstructure ="Reference"
Case 51973
Bomstructure ="Purchased"
Case 51974
Bomstructure ="Inseparable"
Case 51975
Bomstructure = "Varies"
Case Else
Bomstructure = "Unknown"
End Select
MsgBox (Bomstructure)
For Each opropset In oPropSets
If opropset.Name = "Inventor User Defined Properties" Then oUserPropertySet = opropset
Next opropset
' If Property does not exist then add the new Property
On Error Resume Next
Call oUserPropertySet.Add(Bomstructure, "BOM")
' Try to set the Property value if it already exists
For i = 1 To oUserPropertySet.Count
If oUserPropertySet.Item(i).Name = "BOM" Then oUserPropertySet.Item(i).Value = Bomstructure
Next i
End Sub