The Renumber method supports optinal arguments for starting number and increments. Here's a snippet I use for automatically sorting and renumbering my BOMs.
Sub bomSort()
Dim oAsmDoc As AssemblyDocument
Dim oAsmCompDef As AssemblyComponentDefinition
Dim oBOMView As BOMView
oAsmDoc = ThisDoc.Document
oAsmCompDef = oAsmDoc.ComponentDefinition
Try
oBOMView = oAsmCompDef.BOM.BOMViews.Item("Parts Only")
Catch
oAsmCompDef.BOM.PartsOnlyViewEnabled = True
oBOMView = oAsmCompDef.BOM.BOMViews.Item("Parts Only")
End Try
Try
oBOMView.Sort("WORK CENTER CODE", True, "VISUAL PART NUMBER", True, "Description", True)
oBOMView.Renumber()
Catch
MsgBox("Any error was encountered while sorting your BOM. The most likely cause is missing custom properties(WORK CENTER CODE " _
& "& VISUAL PART NUMBER). Please, add these properties and try again.", vbOKOnly, "Error")
Exit Sub
End Try
Try
oBOMView = oAsmCompDef.BOM.BOMViews.Item("Structured")
Catch
oAsmCompDef.BOM.StructuredViewEnabled = True
oBOMView = oAsmCompDef.BOM.BOMViews.Item("Structured")
End Try
Try
oBOMView.Sort("WORK CENTER CODE", True, "VISUAL PART NUMBER", True, "Description", True)
oBOMView.Renumber()
Catch
MsgBox("Any error was encountered while sorting your BOM. The most likely cause is missing custom properties(WORK CENTER CODE " _
& "& VISUAL PART NUMBER). Please, add these properties and try again.", vbOKOnly, "Error")
Exit Sub
End Try
End Sub
Mike (
not Matt) Rattray