I think this will do what you need. It's a VBA macro.
Public Sub ReplaceParts()
' This is used to define the list of old and new file. The first number in
' Dim statement is the number of files in the list. The number is one less
' than the total number since the list starts at zero. The second number
' is always 1.
'
' You can see where the old file and the new file are listed where each pair
' of files has it's own unique first index. For the second index, the old
' filename is 0 and the new filename is 1.
Dim files(3, 1) As String
files(0, 0) = "C:\Users\ekins\OneDrive\Documents\Inventor\Tests\OldTest1.ipt"
files(0, 1) = "C:\Users\ekins\OneDrive\Documents\Inventor\Tests\NewTest1.ipt"
files(1, 0) = "C:\Users\ekins\OneDrive\Documents\Inventor\Tests\OldTest2.ipt"
files(1, 1) = "C:\Users\ekins\OneDrive\Documents\Inventor\Tests\NewTest2.ipt"
files(2, 0) = "C:\Users\ekins\OneDrive\Documents\Inventor\Tests\OldTest3.ipt"
files(2, 1) = "C:\Users\ekins\OneDrive\Documents\Inventor\Tests\NewTest3.ipt"
files(3, 0) = "C:\Users\ekins\OneDrive\Documents\Inventor\Tests\OldTest4.ipt"
files(3, 1) = "C:\Users\ekins\OneDrive\Documents\Inventor\Tests\NewTest4.ipt"
' Specify the folder where the assemlbies to process exist.
Dim folder As String
folder = "C:\Users\ekins\OneDrive\Documents\Inventor\Tests\"
' Iterate through all of the assemblies in the specified folder. This does
' not do subfolders.
Dim assemblyFile As String
assemblyFile = Dir(folder & "*.iam")
Do While assemblyFile <> ""
' Open the current assembly.
Dim asmDoc As AssemblyDocument
Set asmDoc = ThisApplication.Documents.Open(folder & assemblyFile, False)
' Check to see if this assembly references any of the parts in the list.
Dim refDocDesc As DocumentDescriptor
For Each refDocDesc In asmDoc.ReferencedDocumentDescriptors
Dim i As Integer
For i = 0 To UBound(files, 1)
If refDocDesc.ReferencedDocument.FullFileName = files(i, 0) Then
' A match was found, so replace it.
refDocDesc.ReferencedFileDescriptor.ReplaceReference (files(i, 1))
End If
Next
Next
' There's a bug where the display name of the occurrence doesn't always update.
' This resets them to the their default.
Dim occ As ComponentOccurrence
For Each occ In asmDoc.ComponentDefinition.Occurrences
occ.Name = ""
Next
' Save the assembly and close it.
Call asmDoc.Save2(False)
asmDoc.Close
' Get the next assembly.
assemblyFile = Dir()
Loop
MsgBox "Finished."
End Sub
---------------------------------------------------------------
Brian EkinsInventor and Fusion 360 API Expert
Website/Blog:
https://EkinsSolutions.com