- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm wanting to take the Display names of parts and have those names be the part numbers for all the parts in my assembly. I've looked through other forums to try to see if I can bring some iLogic code together but I'm new to it and was unsuccessful. Any ideas on how to easily do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I assume you mean the name plus the instance number? "Plate:1"
Yes I think iLogic would be the only way to do this, but you would need to run the code every time a new part was added.

James W
Inventor UX Designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey, I've already got all the parts in the assembly so I just need to run the iLogic rule once. And the instance wouldn't be needed since the display file names are already set. The reason I don't need instance numbers is because I've got a lot of parts and the duplicates should have the same part number so I get a quantity in the BOM automatically.
I had found this post where some code was made to take the filename and make it the part name for every part in an assembly. this is very similar to I want but I just need to alter the code where instead of taking the Filename it takes the Display name and makes that the part number.
https://forums.autodesk.com/t5/inventor-forum/automatic-setting-filename-to-partnumber/td-p/6819654
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
There's 3 "Part Names", the file path (.ipt), occurrence (what you see in the model tree) & the part number (in iProperties). So you want to change the part number into what the occurrence is?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
yes id want the part number to be what the occurrence is without the occurrence value at the end. Here is an example of some of the occurrence names I've got and I marked it with what values I don't want on the part number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
here you go, i briefly tested it, it should be working ok. Let me know if you have any issues
Sub main iPropPartNumbers End Sub Sub iPropPartNumbers Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition ''' Sub Asm ' Iterate through all Of the occurrences Dim oOccurrence As ComponentOccurrence For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef) ' Searching through the top level assembly file in order to locate only sub assembly files If oOccurrence.DefinitionDocumentType = kAssemblyDocumentObject Then comp = Component.InventorComponent(oOccurrence.Name) Dim CompStrng As String = oOccurrence.Name ' Split the string using ":" as delimiter and get the first element Dim NewName As String = CompStrng.Split(":")(0) ' Create iprop with PS Value iProperties.Value("Project", "Part Number") = NewName ' Write to component iprops On Error Resume Next iProperties.Value(oOccurrence.Name, "Project", "Part Number") = _ iProperties.Value("Project", "Part Number") Else End If Next ''' Piece Parts ' Iterate through all Of the occurrences For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef) ' Searching through the top level assembly file in order to locate only sub assembly files If oOccurrence.DefinitionDocumentType = kPartDocumentObject Then comp = Component.InventorComponent(oOccurrence.Name) Dim CompStrng As String = oOccurrence.Name ' Split the string using ":" as delimiter and get the first element Dim NewName As String = CompStrng.Split(":")(0) ' Create iprop with PS Value iProperties.Value("Project", "Part Number") = NewName ' Write to component iprops On Error Resume Next iProperties.Value(oOccurrence.Name, "Project", "Part Number") = _ iProperties.Value("Project", "Part Number") Else End If Next End Sub