I would like to have a custom column in the BOM editor that is automatically populated when the BOM structure of a part (or assembly) is set as purchased. I am trying to set up a format of columns to be exported to csv and then imported into an MRP system. The MRP system has to have a column that is blank for fabricated parts, but has some sort of indicator (x, $, etc.) for purchased parts. I feel this is possible using iLogic and "If, then" statements; however, I am not familiar with iLogic to be useful.
Thanks,
Nathan Presley
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 If oOcc.Definition.BOMStructure = BOMStructureEnum.kPurchasedBOMStructure
oOcc.Definition.Document.PropertySets.Item("Inventor User Defined Properties").Item("WO#").Value = "S"
End if ' 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
You can try this or something like this - untested so far.
I created a column "WO#" in my test assembly per what I saw in the code. I then pushed that column to all the parts in the assembly to create a custom iproperty. When I run the rule, I get this message: "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))". I am quite novice and don't what to correct, check, or add. Thanks for help. I do appreciate the input.
-Nathan
Did it change any of the files?
It added the custom iproperty to all the parts in the assembly. And "WO#" is selectable as a custom column with the BOM editor. However, the WO# isn't populated for anything.