automating part numbering in project
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I’m working on automating part numbering and file naming in Autodesk Inventor using iLogic to avoid issues with duplicate part numbers and inconsistent filenames in drawings.
The problems I’m trying to solve:
Ensure each part and subassembly has a unique Part Number and File Name
Automatically assign part numbers based on a rule (e.g., sequential or based on custom properties)
Prevent duplicate part numbers across the project (especially in BOMs and drawing titles)
Save each drawing with a name that matches its corresponding part number to avoid confusion and overwrites
Ideally, I would like to:
Automatically apply unique part numbers during modeling or export
Use iLogic to rename files (both models and drawings) based on part number
Synchronize iProperties (Part Number, Title) across model and drawing
Save drawings as both .dwg and .pdf using the same naming logic
Has anyone implemented a system like this with iLogic?
Any working examples or advice would be really appreciated!
' Get the project name from iProperties
Dim ProjectName As String = ThisDoc.Document.PropertySets.Item("Design Tracking Properties").Item("Project").Value
If String.IsNullOrEmpty(ProjectName) Then ProjectName = "PROJ"
' Get the folder path where the file is stored
Dim FolderPath As String = System.IO.Path.GetDirectoryName(ThisDoc.Path)
' Find all existing part files in the same folder that match the naming pattern
Dim files() As String = System.IO.Directory.GetFiles(FolderPath, ProjectName & "-*.ipt")
Dim maxNumber As Integer = 0
' Loop through the files and determine the highest existing number
For Each f As String In files
Dim nameOnly As String = System.IO.Path.GetFileNameWithoutExtension(f)
Dim parts() As String = nameOnly.Split("-"c)
If parts.Length > 1 Then
Dim number As Integer
If Integer.TryParse(parts(parts.Length - 1), number) Then
If number > maxNumber Then maxNumber = number
End If
End If
Next
' Create the next available number, e.g. 001, 002, etc.
Dim nextNumber As String = (maxNumber + 1).ToString("D3")
Dim newPartNumber As String = ProjectName & "-" & nextNumber
' Set the Part Number and Description
iProperties.Value("Project", "Part Number") = newPartNumber
iProperties.Value("Project", "Description") = newPartNumber
' Rename the file if needed
Dim newFileName As String = newPartNumber & ".ipt"
Dim fullPath As String = System.IO.Path.Combine(FolderPath, newFileName)
If ThisDoc.FileName <> newFileName Then
ThisDoc.Document.SaveAs(fullPath, True)
End If
can some one help`?