Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Change part number to filename for all parts and subs in a assembly

nuclair
Contributor

Change part number to filename for all parts and subs in a assembly

nuclair
Contributor
Contributor

Hi All!

 

For a i'm going to migrate a lot of files from solidworks to inventor and later push them in to the Autodesk Vault.

They did not use a lot of logic in the partnumbers so i'm trying to implement a new numbering logic while migrating to inventor.

 

Therefore i'm changing the filenames in the windows filebrowser but i'm experiencing that the part number is not the same as the filenumber when I change the name in the filebrowser.

 

1. Is there a better way to do the above?

2. Is there a piece of code to change the Part number in to the filename for all parts and subs in a assembly?

 

Thanks in advance!

0 Likes
Reply
Accepted solutions (1)
231 Views
2 Replies
Replies (2)

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

Hi @nuclair . This iLogic code takes the filename and writes it to the Part Number property. This code must be run in the main assembly.

 

Dim oADoc As AssemblyDocument = TryCast(ThisDoc.Document, AssemblyDocument)
For Each oRefDoc As Document In oADoc.AllReferencedDocuments
	Dim sName As String = System.IO.Path.GetFileNameWithoutExtension(oRefDoc.FullFileName)
	Try : oRefDoc.PropertySets("Design Tracking Properties")("Part Number").Value = sName
	Catch : Continue For : End Try
Next

 

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes

nuclair
Contributor
Contributor
Thank you so much! This works like a charm.

If there are any more tips for migrating from solidworks to inventor (+renaming/migrating to vault) i'm open for all suggestions.
0 Likes