Hello,
I have a learnt a lot of things from this forum and you guys. I was always getting answers to my questions related to Inventor from here.
This is my first quesiotn that i am posting here as i was unable to find answers this time. I will be glad for the support.
I have a machine assembly with old part naming. Now we have a new part naming system. So i am supposed to rename all existing parts, assemblies to new naming system.
Eg: A machine assembly with old names (lets say part1, part2..... part1000). It has to be renamed to new names (say item1, item2.....item1000).
"part1" should be renamed as "item1" and so on.
Design assistant is not a good option because its a lot of manual work, its same issue with using Vault.
Please suggest if it is possible to perform this task.
Any guidance would be appriciated!
Thanks in advance.
BR,
Rajesh
You can try below VBA code to replace occurrences' names:
Sub RenameOccurrencesSample() Dim oAssyDoc As AssemblyDocument Set oAssyDoc = ThisApplication.ActiveDocument Dim sReplaceStr As String, sReplacedStr As String sReplacedStr = InputBox("Please type the string being replaced in occurrence name", "Rename Occurrence") sReplaceStr = InputBox("Please type the new string to replace the old name", "Rename Occurrence") Dim oOccurrence As ComponentOccurrence For Each oOccurrence In oAssyDoc.ComponentDefinition.Occurrences Dim sOldName As String, sNewName As String sOldName = oOccurrence.Name Dim iIndex As Integer iIndex = 0 iIndex = InStr(1, LCase(sOldName), LCase(sReplacedStr)) If iIndex > 0 Then sNewName = Left(sOldName, iIndex - 1) & sReplaceStr & Right(sOldName, Len(sOldName) - iIndex - Len(sReplacedStr) + 1) Debug.Print sNewName oOccurrence.Name = sNewName End If Next End Sub
but if your occurrences have a name like "Part1Part1", you should modify the VBA code to consider this case, and also if you want to rename the occurrences in sub assembly you also can modify the code to iterate to the sub assembly to rename them.
Hope this helps!
Hello Rocky,
Thank you for the input.
It works partially. Your code renames only the occurances.
My requirement is to rename the file name itself.
Could you please give me some more?
BR,
Rajesh
Oh, seems your requirement is as below:
1. Rename the referenced files by an assembly.
2. Re-reference the renamed files to the assembly to replace the old ones. With this step the occurrences' names should also change automatically.
There is a tool in Inventor SDK named CopyDesign which can do part of the job, but it only can add prefix to the referenced files, so you can modify the tool to satisfy your requirement. You can find the tool after you install the UserTools.msi, the path is:
[win7] C:\Users\Public\Documents\Autodesk\Inventor 20XX\SDK\UserTools\CopyDesign
[winxp] C:\Program Files\Autodesk\Inventor 20xx\SDK\UserTools\CopyDesign
Hope this can help you.
Hi.
I have looked into the SDK tool, it looks like i can use by modifying few codes.
I will get back to you if and when i get the answer to my problem 🙂
Thank you!
Hi Rajesh, Did you find an exact solution to your problem. I am facing the same issue. Could you please guide me on the steps to achieve batch renaming?