Matching item #'s

Matching item #'s

andrewiv
Mentor Mentor
1,600 Views
8 Replies
Message 1 of 9

Matching item #'s

andrewiv
Mentor
Mentor

I'm wanting to make an iLogic rule that will look at an assembly BOM and match the item number from a sub assembly to the assembly BOM.  I was just wondering if anyone had already attempted this and if it is even possible.

 

Here is a link to an Inventor forum topic describing what I'm trying to do.

https://forums.autodesk.com/t5/inventor-forum/matching-item-numbers-for-multi-level-bom/m-p/7996328#...

Andrew In’t Veld
Designer / CAD Administrator

0 Likes
Accepted solutions (1)
1,601 Views
8 Replies
Replies (8)
Message 2 of 9

chandra.shekar.g
Autodesk Support
Autodesk Support

@andrewiv,

 

Hoping that below iLogic code may help.

Sub Main()
    Dim asm As AssemblyDocument
    asm = ThisApplication.ActiveDocument

    Dim b As BOM
    b = asm.ComponentDefinition.BOM

    b.StructuredViewDelimiter = ""

    b.StructuredViewEnabled = True

    Dim bv As BOMView
    bv = b.BOMViews("Structured")
    Dim cnt As Integer

    Call RenameItemNumber(bv.BOMRows, cnt)

End Sub

Sub RenameItemNumber(rows As BOMRowsEnumerator, ByRef cnt As Integer)
    Dim row As BOMRow
    Dim i As Integer

    For i = 1 To rows.Count Step 1
        cnt = cnt + 1
        row = rows.Item(i)
        row.ItemNumber = cnt.ToString
        If Not row.ChildRows Is Nothing Then
            RenameItemNumber(row.ChildRows, cnt)
        End If
    Next
End Sub

 

BOM before running codeBOM before running codeBOM after running codeBOM after running code

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 9

andrewiv
Mentor
Mentor

That's not exactly what I'm looking for.  I would like to look at the item #'s in the sub assembly BOM and make the number after the period match in the top assembly, then sort the BOM by the item #.  If I could put the part numbers in the same order and then renumber the whole BOM that would be the same thing.

 

Top level beforeTop level beforeSub assembly BOMSub assembly BOMWhat I want the Top level to look like afterWhat I want the Top level to look like after

Andrew In’t Veld
Designer / CAD Administrator

0 Likes
Message 4 of 9

YuhanZhang
Autodesk
Autodesk
Accepted solution

Here is VBA sample to do this, it just consider one level sub assembly in the top assembly, you can change it if you have multiple levels:

 

Sub SyncBOMRowOrderFromSubAssembly()
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oBOM As BOM
    Set oBOM = oDoc.ComponentDefinition.BOM
    oBOM.StructuredViewEnabled = True
    
    Dim oStructedView As BOMView
    Set oStructedView = oBOM.BOMViews("Structured")
    
    Dim oRow As BOMRow, oChildRow As BOMRow
    Dim oSubDoc As AssemblyDocument, oSubBOM As BOM, oSubStructedView As BOMView, oSubRow As BOMRow
    Dim sItemNum() As String, sUpdateItemNum As String
    For Each oRow In oStructedView.BOMRows
        If oRow.ComponentDefinitions.Item(1).Type = kAssemblyComponentDefinitionObject Then
            If oRow.ChildRows.Count > 1 Then
                Set oSubDoc = oRow.ComponentDefinitions(1).Document
                Set oSubBOM = oSubDoc.ComponentDefinition.BOM
                oSubBOM.StructuredViewEnabled = True
                
                Set oSubStructedView = oSubBOM.BOMViews("Structured")
                
                For Each oSubRow In oSubStructedView.BOMRows
                    For Each oChildRow In oRow.ChildRows
                        Debug.Print oChildRow.ReferencedFileDescriptor.FullFileName
                        If StrComp(LCase(oSubRow.ReferencedFileDescriptor.FullFileName), LCase(oChildRow.ReferencedFileDescriptor.FullFileName)) = 0 Then
                            sItemNum = Split(oChildRow.ItemNumber, ".")
                            oChildRow.ItemNumber = oSubRow.ItemNumber
                            Exit For
                        End If
                    Next
                Next
            End If
        End If
    Next
    
    oStructedView.Sort "Item", True
End Sub

 

Hope it works for you.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 5 of 9

andrewiv
Mentor
Mentor

Thank you for the code.  I do need it to go deeper than 2 levels, but I can tweak it myself to accomplish that. 

 

I was wondering if this was on the radar for implementation in the base product.  @dan_szymanski can you comment on this?  I would be more than willing to work with Autodesk to beta test or provide input on functionality.

 

Here is a link to an idea that was posted and one of the comments in there is that there should be an application option to enable parametric operation between a single level and a multi level BOM.  I think that this would solve the issue and still retain the current functionality if anyone needs to use it as it is today.

https://forums.autodesk.com/t5/inventor-ideas/assembly-bom-propagate-item-number-to-children/idi-p/4...

Andrew In’t Veld
Designer / CAD Administrator

0 Likes
Message 6 of 9

dan_szymanski
Autodesk
Autodesk

Hi Andrew, 

Yes this request is on our radar (as indicated by the "Future Consideration" status).  However it is not on any list for short term consideration.  We will definitely keep you in mind for validation if the wheels on this one start turning...

As always, thanks.

-Dan

Dan Szymanski
Sr. Product Manager
Autodesk, Inc.




Message 7 of 9

JBerns
Advisor
Advisor

@YuhanZhang / @andrewiv ,

 

Could the code above be adapted to work with a top-level assembly that uses the Parts Only tab instead of the Structured tab? The top-level assembly would contain subassemblies and parts.

 

After creating a subassembly view, we would like the balloon number (item) of a component to match the item number at the top-level. I appreciate the complexity of this request. I am hoping some code can eliminate the repetitive, manual item number overrides required.

 

Our current "workaround" is to create multiple views of the top-level assembly and use ViewReps to show just the subassembly we want to document.

 

Thanks for your time and attention. I look forward to your replies.

 

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 8 of 9

YuhanZhang
Autodesk
Autodesk

Hi Jerry,

 

My code sample is just working for the Structured BOM view and with one level sub assembly in the top assembly. If you want to handle the Parts Only BOM view you need to modify it somewhat to just query the Parts Only BOM view instead, and the components in Parts Only BOM view is flat so it is simpler than the Structured. Then you can just query the component's Item Number in the Parts Only BOM view and update the Balloon in drawing.

 

Hope this clears.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 9 of 9

JBerns
Advisor
Advisor

Acknowledged. Thanks, Rocky.

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes