03-08-2021
06:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-08-2021
06:46 AM
OK. Maybe try it this way then.
Sub Main
'source document
Dim oSDoc As PartDocument = ThisApplication.ActiveDocument
Dim oSUParams As UserParameters = oSDoc.ComponentDefinition.Parameters.UserParameters
Dim oSUParam As UserParameter
'target document
Dim oTDoc As AssemblyDocument = ThisApplication.Documents.Add(kAssemblyDocumentObject, "{source Assy filepath}", True)
Dim oTUParams As UserParameters = oTDoc.ComponentDefinition.Parameters.UserParameters
Dim oTUParam As UserParameter
For Each oSUParam In oSUParams
If Not oSUParam.IsKey Then Continue For 'so it will only process Key params
If oSUParam.Units = "ul" Then
oTUParam = oTUParams.AddByExpression(oSUParam.Name, oSUParam.Value, "ul")
oTUParam.IsKey = True
CopyExpList(oSUParam,oTUParam)
ElseIf oSUParam.Units = "Text" Then
oTUParam = oTUParams.AddByValue(oSUParam.Name, oSUParam.Value, kTextUnits)
oTUParam.IsKey = True
CopyExpList(oSUParam,oTUParam)
Else
oTUParam = oTUParams.AddByValue(oSUParam.Name, oSUParam.Value, kMillimeterLengthUnits)
oTUParam.IsKey = True
CopyExpList(oSUParam,oTUParam)
End If
Next
End Sub
Public Sub CopyExpList(oSourceP As UserParameter, oTargetP As UserParameter)
If oSourceP.ExpressionList IsNot Nothing AndAlso oSourceP.ExpressionList.Count > 0 Then
oTargetP.ExpressionList.SetExpressionList(oSourceP.ExpressionList.GetExpressionList)
End If
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS)
.
Wesley Crihfield
(Not an Autodesk Employee)