You can do this with some simple iLogic Rules:
How to modify the component names in Inventor model browser : Geo-IT (Dutch)
This iLogic Rule will give you the part numbers in the model browser:
Sub main()
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
Call TraverseAssembly(oAsmDoc.ComponentDefinition.Occurrences)
End Sub
Private Sub TraverseAssembly(Occurrences As ComponentOccurrences)
On Error Resume Next
Dim oOcc As ComponentOccurrence
Dim lngPos As Long
Dim IndexValue As String ' Renamed from "Index" to "IndexValue"
For Each oOcc In Occurrences
If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
Call TraverseAssembly(oOcc.SubOccurrences)
End If
lngPos = InStrRev(oOcc.Name, ":", -1)
IndexValue = "" ' Initialize IndexValue variable
IndexValue = Trim(Mid(oOcc.Name, lngPos, Len(oOcc.Name)))
' Use the renamed variable to update the occurrence name
oOcc.Name = oOcc.Definition.Document.PropertySets.Item(3).Item("Part Number").Value & IndexValue
Next
End Sub
This iLogic Rule will give you the Description in the Model Browser
Sub main()
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
Call TraverseAssembly(oAsmDoc.ComponentDefinition.Occurrences)
End Sub
Private Sub TraverseAssembly(Occurrences As ComponentOccurrences)
On Error Resume Next
Dim oOcc As ComponentOccurrence
Dim lngPos As Long
Dim IndexValue As String ' Renamed variable from "Index" to "IndexValue"
For Each oOcc In Occurrences
If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
Call TraverseAssembly(oOcc.SubOccurrences)
End If
lngPos = InStrRev(oOcc.Name, ":", -1)
IndexValue = "" ' Initialize the new IndexValue variable
IndexValue = Trim(Mid(oOcc.Name, lngPos, Len(oOcc.Name)))
' Use the renamed variable to update the occurrence name
oOcc.Name = oOcc.Definition.Document.PropertySets.Item(3).Item("Description").Value & IndexValue
Next
End Sub
This iLogic rule will give you PartNumber & Description in the model browser:
Sub main()
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
Call TraverseAssembly(oAsmDoc.ComponentDefinition.Occurrences)
End Sub
Private Sub TraverseAssembly(Occurrences As ComponentOccurrences)
On Error Resume Next
Dim oOcc As ComponentOccurrence
Dim lngPos As Long
Dim IndexValue As String ' Renamed from "Index" to "IndexValue"
For Each oOcc In Occurrences
If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
Call TraverseAssembly(oOcc.SubOccurrences)
End If
lngPos = InStrRev(oOcc.Name, ":", -1)
IndexValue = "" ' Initialize IndexValue variable
IndexValue = Trim(Mid(oOcc.Name, lngPos, Len(oOcc.Name)))
' Use the renamed variable to update the occurrence name
oOcc.Name = oOcc.Definition.Document.PropertySets.Item(3).Item("Part Number").Value & " (" & oOcc.Definition.Document.PropertySets.Item(3).Item("Description").Value & ")" & IndexValue
Next
End Sub