iLogic to renumber partlist in assembly

iLogic to renumber partlist in assembly

Anonymous
Not applicable
1,903 Views
4 Replies
Message 1 of 5

iLogic to renumber partlist in assembly

Anonymous
Not applicable

Hello,
I am searching for a code snipped to renumber the partlist in an assembly with start by 1 and ingrement by 1.
I only found some codes for the partlist in drawing documents.

Anyone who already uses something like that?

0 Likes
Accepted solutions (2)
1,904 Views
4 Replies
Replies (4)
Message 2 of 5

HermJan.Otterman
Advisor
Advisor
Accepted solution

Look in Inventor, in the API help,

 

you can use this

BOMView.Renumber Method BOMView.Renumber( [StartValue] As Long, [Increment] As Long, [BOMRowsToRenumber] As Variant )

 

also from the help:

 

Using the BOM APIs API Sample

' Set a reference to the assembly document.
    ' This assumes an assembly document is active.
    Dim oDoc As AssemblyDocument
    oDoc = ThisApplication.ActiveDocument

    Dim FirstLevelOnly As Boolean
    If MsgBox("First level only?", vbYesNo) = vbYes Then
        FirstLevelOnly = True
    Else
        FirstLevelOnly = False
    End If
    
    ' Set a reference to the BOM
    Dim oBOM As BOM
    oBOM = oDoc.ComponentDefinition.BOM
    
    ' Set whether first level only or all levels.
    If FirstLevelOnly Then
        oBOM.StructuredViewFirstLevelOnly = True
    Else
        oBOM.StructuredViewFirstLevelOnly = False
    End If
    
    ' Make sure that the structured view is enabled.
    oBOM.StructuredViewEnabled = True
    
    'Set a reference to the "Structured" BOMView
    Dim oBOMView As BOMView
     oBOMView = oBOM.BOMViews.Item("Structured")

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 3 of 5

Anonymous
Not applicable

This one works for me... (Frankensteined from @Anonymous and others)

 

You can sort by anything in the list: "0" is descending, "1" is ascending.

 

'sort parts list by PART NUMBER
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oPartsList As PartsList
oPartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1)

If Not oPartsList Is Nothing Then 
'sort by part number Call oPartsList.Sort("PART NUMBER", 1, "ITEM QTY", 1)
'renumber the parts list oPartsList.Renumber
'save overrides to BOM oPartsList.SaveItemOverridesToBOM End If

 

Message 4 of 5

Anonymous
Not applicable

First of all thanks for the help. 🙂

Herman, your code does resort the partlist in assemblies with a structure, but it doesnt renumber the items (parts). Maybe the info in the api can help. Hopefully it does. 😄

Curtis code renumber the parts, but only in drawings. I have no drawing for the assembly, because we export the partlist as excel sheets.

0 Likes
Message 5 of 5

Anonymous
Not applicable
Accepted solution

With Hermans code snipped I found the correct code in the forum to renumber the parts in assembly.

https://forums.autodesk.com/t5/inventor-customization/bomview-renumber/td-p/6885184

 

 

Thanks for the help! 🙂