Hi @karram . Try this code. It can copy in any combination: Assembly - Assembly, Assembly - Detail, Detail - Detail, Detail - Assembly.
Sub main
Dim oDoc As Document = ThisApplication.ActiveDocument
If TypeOf oDoc Is AssemblyDocument Then
Dim oCM As CommandManager = ThisApplication.CommandManager
Dim oTm As TransactionManager = ThisApplication.TransactionManager
Dim oADoc As AssemblyDocument = oDoc
Dim oCompCopy, oCompPaste As ComponentOccurrence
Do
oCompCopy = oCM.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select component copy params...")
If oCompCopy Is Nothing Then Exit Sub
Loop While Not oCompCopy.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Or _
oCompCopy.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject
Do
oCompPaste = oCM.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select component paste params...")
If oCompPaste Is Nothing Then Exit Sub
Loop While Not oCompPaste.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Or _
oCompPaste.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject
Dim newTM As Transaction = oTm.StartTransaction(oADoc, "CopingUserParameters")
Call CreateParamsInAssembly(oCompPaste.Definition.Parameters, oCompCopy.Definition.Parameters)
newTM.End()
oADoc.Update()
Else
MessageBox.Show("Active document is not AssemblyDocument.", "Error!",MessageBoxButtons.OK,MessageBoxIcon.Error)
End If
End Sub
Private Function CreateParamsInAssembly(oParams As Parameters, ByVal copyParams As Parameters)
Dim bCreatParam As Boolean
For Each copyParam As UserParameter In copyParams.UserParameters
bCreatParam = True
For Each oParam As UserParameter In oParams.UserParameters
If oParam.Name = copyParam.Name Then
bCreatParam = False
Try
oParam.Value = copyParam.Value
Catch
oParam.Expression = copyParam.Expression
End Try
End If
Next
If bCreatParam Then
oParams.UserParameters.AddByExpression(copyParam.Name, copyParam.Expression, copyParam.Units)
End If
Next
End Function