BOM with iLogic Custom Item Number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello (this turned out to be a long read)
I'm working on automating customization of BOM Item Number (column) similarity to this old post but tackled with iLogic.
https://forums.autodesk.com/t5/inventor-forum/custom-numbering-in-bom/m-p/8306703#M714849
(Note: I'm restricted to Inventor version 2021)
The reason: Streamline manufacturing of construction components (in my case)
Main purpose of this is to prepare documentation in such a way, so to simplify production of construction elements (plates, I beams, C beams etc...) and it's assemblies.
As I was made aware, commonly construction manufacturers stamp components for easier identification with numbers (either painting, or punching in with dies), so the idea is to simplify the process, to assign each element a number, place it somewhere visibly on the drawing, for the manufacturer to identify quickly for stamping and managing.
In short, I'd like to Overwrite the BOM Item Number order and values with custom ones via iLogic if possible. The effect would be to sort and then assign each (Normal type) Part/Assembly, a number (like iParts have) and to assign that number in the BOM as it's item number, overwriting it in each assembly.
I'd like this to work specifically with the default BOM Item Numbers, so it includes content center fasteners which have every BOM column "frozen" as read only except for Item Number. This wouldn't require any specific customized drawing BOM styles.
You could generate a custom parameter in parts/Assemblies, and then generate continous numbers, make a custom bom style to utilize that custom user parameter instead of the regular item Number, but this method does not include CC content fasteners (as read only), and I'd like to avoid having both custom item number and regular Item Number in the drawing BOM to avoid confusion.
Trying to include fasteners in the renumbering so they have preassigned consistent Item Numbers (per project) throughout every assembly/subassembly might not be possible, as each assembly/subassembly has a separate Item Numer table.
I'm aware that Inventor wasn't designed for this specifically, maybe this achievable with iLogic to an extent.
Let me explain my current workflow how I do it manually
1.
- in the top level assembly, open up the BOM Parts Only table
- sort it (usually by BOM Structure Type) so all the Purchased items are last and with a second leading column like Description or sth.
- renumber the Parts only Item number starting from 001
- transfer the numbers (Copy/paste) to a iPorperity column "Adres WWW" (preferred) (Polish localization) which is the web adres standard iProperity (Project Tab) that I adapted as we do not utilize it in any way.
2.
- switch to Structural BOM list
- sort it
- (main issue) manually assign a two digit number to Item Number to assembly/+subassembly files all the way down through the assembly structure. this can take long, depending on the size and structure of the assemblies, and copy that to the "Adres WWW"
- for any part that was reordered in the previous step (in "Parts only BOM"), transfer assigned numbers from the "Adres WWW" iProperity to the Item Number column.
So the idea is to sort and renumber (Normal state) components in the Parts Only BOM list with three digit numbers, and (Normal state) Assembly components with two digit numbers in the Structural BOM list, transfer those numbers to an existing unused iProperity field (preferrably "the web adres" field), or a custom parameter.
Keep those numbers persistent in all BOM' in multi-sheet drawings
As fasteners could be present on different levels of assemblies/sub-assemblies they might be handled separately, and renumbered on each drawing by a separate rule targeting only "purchased" items, with three digits starting from 901 (for example), so it would,'t have to be persistent as it has no impact on manufacturing stage.
Finally for some work that I've done with mixed results.
First approach was to automate renumbering just the Assemblies and do the rest manually.
Go through the project through all assembly files, check if they're Normal type (Not Purchased/Phantom/Reference/etc.) if check is fine, Assign a two digit number to a preferred unused iProperity field (in my case "Adres WWW")
Below code somewhat worked, but it does not account for BOM sorting, it goes through the assembly Model browser with order in which files were inserted into the main assembly, and also while it generated two digit numbers, there were still some inconsistencies, the rule skipped some numbers, they were not consecutive, though all the proper Normal type assemblies had numbers.
Second issue, I could not find proper reference to insert the numbers to "Adres WWW" (web adress iProperity) in Inventor version 2021, so for test purposes i used "Engineer" iProperity (they seem to be in same iProperity Tab)
Imports Inventor
Imports System.IO
Imports Microsoft.VisualBasic.Interaction
' Import necessary namespaces
Sub Main()
' Prompt the user for the starting value
Dim startValueStr As String = InputBox("Enter the starting value (two digits):", "Starting Value", "01")
' Validate the input
Dim startValue As Integer
If Not Integer.TryParse(startValueStr, startValue) OrElse startValue < 0 OrElse startValue > 99 Then
MessageBox.Show("Invalid input. Please enter a two-digit number between 00 and 99.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
' Get the active document
Dim doc As Document = ThisApplication.ActiveDocument
' Ensure the document is an assembly
If doc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MessageBox.Show("Please run this rule in an assembly document.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
' Get the components of the assembly
Dim asmDoc As AssemblyDocument = doc
' Iterate through all components recursively and update the Engineer property for kNormalBOMStructure assemblies
ProcessComponents(asmDoc.ComponentDefinition.Occurrences, startValue)
End Sub
Sub ProcessComponents(components As ComponentOccurrences, ByRef currentValue As Integer)
For Each comp As ComponentOccurrence In components
' Check if the component is an assembly and has normal BOM structure (kNormalBOMStructure)
If comp.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject AndAlso _
comp.BOMStructure = BOMStructureEnum.kNormalBOMStructure Then
' Update the Engineer property for this assembly
SetEngineerProperty(comp.Definition.Document, currentValue)
currentValue += 1
If currentValue > 99 Then currentValue = 0 ' Reset to 00 after 99
' Recursively process subassemblies
ProcessComponents(comp.SubOccurrences, currentValue)
End If
Next
End Sub
Sub SetEngineerProperty(doc As Document, value As Integer)
' Get the Design Tracking Properties
Dim designTrackingProperties As PropertySet = doc.PropertySets.Item("Design Tracking Properties")
Dim engineerProp As [Property] = Nothing
' Check if the Engineer property exists
Try
engineerProp = designTrackingProperties.Item("Engineer")
Catch ex As Exception
' If the property does not exist, create it
engineerProp = designTrackingProperties.Add("", "Engineer")
End Try
' Set the Engineer property to a two-digit value
engineerProp.Value = value.ToString("D2")
End Sub
Then I dabbled a bit with approach to access the BOM lists (Parts only), but couldn't transfer the sorted Item Number, to the preferred iProperity column, either "Adres WWW" or "Inzynier" (localized names)
I'd like also to expand the sorting for it to include Descriptrion column "Opis", and ofc copying
' Set a reference to the assembly document.
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
' Set a reference to the BOM
Dim oBOM As BOM
oBOM = oAsmDoc.ComponentDefinition.BOM
' Ensure the desired BOM view is enabled
Dim BOMViewName As String = "Tylko części" ' Options: "Structured" or "Parts Only"
Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.Item(BOMViewName)
' Sort the BOM by a specific column
Dim SortColumn As String = "Typ w strukturze zestawienia BOM" ' Replace with the desired column name
oBOMView.Sort(SortColumn, True) ' True for ascending, False for descending
' Renumber the BOM items starting from 001
Dim oBOMRows As BOMRowsEnumerator
oBOMRows = oBOMView.BOMRows
Dim i As Integer = 1
For Each oRow As BOMRow In oBOMRows
oRow.ItemNumber = i.ToString("D3")
i += 1
Next
This is where I thought that I need help for this to get it working as intended.
If anyone has a different approach for the same effect, with less of a hassle, then I'm all ears.
Regards
Marcin
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.