Note: This code was written with Claude.ai (and a lot of prompts to get it right)
Here is an updated version of the above "attempt". The way this code works is that it allows a specifically listed set of "part files" that will be the controlling parameters for a specific list of assembly(s) or Part(s) files that will be affected.
In other words, specific assemblies and/or parts that are linked to specific part files will automatically update and include any new parameters added to the specific list of part files that the specific list of assemblies/parts are linked to. (hopefully you got that, lol)
All you have to do is change your list of parts files that the assemblies/parts will link to, and add a list of assemblies/parts that will be linked and this code should handle the rest. You can set the trigger for each assembly to be "before save" to trigger the update if you like.
See screen show for what parts of the code to change.

Sub Main()
' Create list to store parameter information
Dim addedParameters As New System.Collections.Generic.List(Of String)
' The specific parameter files we want to use as sources
Dim parameterFiles As New System.Collections.Generic.List(Of String)
parameterFiles.Add("Linked Part-01.ipt")
parameterFiles.Add("Linked Part-02.ipt")
parameterFiles.Add("Linked Part-03.ipt")
' Get the current document
Dim currentDoc As Document = ThisDoc.Document
' List of documents (assemblies and parts) that should have parameters updated
Dim targetDocuments As New System.Collections.Generic.List(Of String)
' Assemblies
targetDocuments.Add("Assembly Using Links-01.iam")
targetDocuments.Add("Assembly Using Links-02.iam")
targetDocuments.Add("Assembly Using Links-03.iam")
' Parts
targetDocuments.Add("Part Using Links-01.ipt")
targetDocuments.Add("Part Using Links-02.ipt")
targetDocuments.Add("Part Using Links-03.ipt")
' Check if current document is one of our target documents
Dim currentFileName As String = System.IO.Path.GetFileName(currentDoc.FullFileName)
Dim isTargetDocument As Boolean = False
For Each docName As String In targetDocuments
If String.Compare(currentFileName, docName, True) = 0 Then
isTargetDocument = True
Exit For
End If
Next
If Not isTargetDocument Then
Dim message As String = "This document (" & currentFileName & ") is not in the list of documents to update." & vbCrLf & _
"Please open one of the following documents:" & vbCrLf
For Each docName As String In targetDocuments
message &= "- " & docName & vbCrLf
Next
MessageBox.Show(message, "Not a Target Document")
Return
End If
' Verify the current document is a part or assembly (has parameters)
If Not (TypeOf currentDoc Is PartDocument OrElse TypeOf currentDoc Is AssemblyDocument) Then
MessageBox.Show("The current document type is not supported." & vbCrLf & _
"Only parts (.ipt) and assemblies (.iam) can have parameters updated.", _
"Unsupported Document Type")
Return
End If
' Find and update parameters from each parameter file
Dim totalSourcesProcessed As Integer = 0
Dim totalSourcesFound As Integer = 0
For Each parameterFileName As String In parameterFiles
' Find the parameter file in the project
Dim paramFilePath As String = FindFileInProject(parameterFileName)
totalSourcesProcessed += 1
If String.IsNullOrEmpty(paramFilePath) Then
addedParameters.Add("WARNING: Could not find '" & parameterFileName & "' in the active project.")
Else
totalSourcesFound += 1
addedParameters.Add("===== Processing parameters from " & parameterFileName & " =====")
' Update parameters from this parameter file
UpdateParametersFromFile(currentDoc, paramFilePath, addedParameters)
addedParameters.Add("") ' Add blank line for separation
End If
Next
' Show results to the user
If addedParameters.Count > 0 Then
Dim resultMessage As String = String.Format(
"Parameter Update Results ({0} of {1} parameter files found):" & vbCrLf & vbCrLf,
totalSourcesFound,
totalSourcesProcessed)
For Each param As String In addedParameters
resultMessage &= param & vbCrLf
Next
MessageBox.Show(resultMessage, "Parameter Update Results")
Else
MessageBox.Show(String.Format(
"No parameters were updated. ({0} of {1} parameter files found)",
totalSourcesFound,
totalSourcesProcessed),
"Parameter Update Results")
End If
End Sub
' Find a file in the active project by filename
Function FindFileInProject(ByVal fileName As String) As String
Try
' Get the active project
Dim project As DesignProject = ThisApplication.DesignProjectManager.ActiveDesignProject
' Store the result
Dim foundFilePath As String = ""
' First try to find in workspace folder directly
Dim workspacePath As String = project.WorkspacePath
Dim potentialPath As String = System.IO.Path.Combine(workspacePath, fileName)
If System.IO.File.Exists(potentialPath) Then
Return potentialPath
End If
' Next try the registered project paths
For Each folder As ProjectPath In project.WorkspaceFolders
potentialPath = System.IO.Path.Combine(folder.Path, fileName)
If System.IO.File.Exists(potentialPath) Then
Return potentialPath
End If
' Also try subfolders (one level deep)
Try
For Each subfolder As String In System.IO.Directory.GetDirectories(folder.Path)
potentialPath = System.IO.Path.Combine(subfolder, fileName)
If System.IO.File.Exists(potentialPath) Then
Return potentialPath
End If
Next
Catch
' Skip if we can't access subfolders
End Try
Next
Return "" ' File not found
Catch ex As Exception
Return "" ' Return empty on error
End Try
End Function
' Update parameters from the specified file to the current document
Sub UpdateParametersFromFile(ByVal currentDoc As Document, ByVal parameterFilePath As String, ByRef addedParameters As System.Collections.Generic.List(Of String))
Try
' Remember parameters before update
Dim beforeParams As New System.Collections.Generic.Dictionary(Of String, String)
For Each param As UserParameter In currentDoc.ComponentDefinition.Parameters.UserParameters
beforeParams.Add(param.Name, param.Expression)
Next
' Open the parameter document
Dim paramDoc As Document = ThisApplication.Documents.Open(parameterFilePath, False)
If Not (TypeOf paramDoc Is PartDocument) Then
addedParameters.Add("ERROR: Parameter file is not a part document.")
paramDoc.Close(False)
Return
End If
Dim paramPartDoc As PartDocument = paramDoc
' Make sure we have a modifiable document
If Not currentDoc.IsModifiable Then
addedParameters.Add("ERROR: Current document is read-only or locked.")
paramDoc.Close(False)
Return
End If
' Create a collection for the parameters
Dim paramCollection As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
' Get simple filename for reporting
Dim paramFileName As String = System.IO.Path.GetFileName(parameterFilePath)
' Check if there are user parameters to link
If paramPartDoc.ComponentDefinition.Parameters.UserParameters.Count = 0 Then
addedParameters.Add("Parameter file contains no user parameters.")
paramDoc.Close(False)
Return
End If
' Add all user parameters from parameter file to collection
For Each param As UserParameter In paramPartDoc.ComponentDefinition.Parameters.UserParameters
paramCollection.Add(param)
Next
' Find or create the derived parameter table
Dim paramTable As DerivedParameterTable = Nothing
Dim isNewTable As Boolean = True
' Check for existing table
For Each table As DerivedParameterTable In currentDoc.ComponentDefinition.Parameters.DerivedParameterTables
If table.ReferencedDocumentDescriptor.FullDocumentName = parameterFilePath Then
paramTable = table
isNewTable = False
Exit For
End If
Next
' Create new table if needed
If paramTable Is Nothing Then
paramTable = currentDoc.ComponentDefinition.Parameters.DerivedParameterTables.Add(parameterFilePath)
addedParameters.Add("Created new parameter table for " & paramFileName)
End If
' Set parameters to table and update
paramTable.LinkedParameters = paramCollection
' Compare parameters to see what was added or changed
Dim afterParams As New System.Collections.Generic.Dictionary(Of String, String)
For Each param As UserParameter In currentDoc.ComponentDefinition.Parameters.UserParameters
afterParams.Add(param.Name, param.Expression)
Next
' Find new and changed parameters
Dim changes As Integer = 0
For Each kvp As KeyValuePair(Of String, String) In afterParams
If Not beforeParams.ContainsKey(kvp.Key) Then
' This is a new parameter
addedParameters.Add("ADDED: " & kvp.Key & " = " & kvp.Value)
changes += 1
ElseIf beforeParams(kvp.Key) <> kvp.Value Then
' This parameter changed value
addedParameters.Add("UPDATED: " & kvp.Key & " from " & beforeParams(kvp.Key) & " to " & kvp.Value)
changes += 1
End If
Next
' Report if no changes
If changes = 0 Then
addedParameters.Add("All parameters were already up to date")
End If
' Close the parameter file
paramDoc.Close(False)
Catch ex As Exception
addedParameters.Add("ERROR: " & ex.Message)
End Try
End Sub