Hi @pranaykapse1. I know how to copy a parameter from the 'active' part on my screen, which has another part derived into it, to that derived in part. And I know how to copy a parameter from a part that is derived into my 'active' part, to the 'active' part on my screen. But that is only possible when the 'link' (dependency) to the derived in part has not been suppressed or broken. But the other part (the part that is derived into this one) does not know that it it associated with 'this' part in any way, because it will not contain anything pointing to 'this' part. So, you could not start with that derived in part as the 'active' one on your screen, then copy a parameter to the part that it is derived into. Similar to a part not knowing that it is being used in a hundred assemblies, because there is nothing in the part that tells it about those hundred assemblies. If you need to start your code from the part that is being derived into other stuff, then you could probably just include the FullFileName (or FullDocumentName) of the 'other' part that this one is being derived into within your code, so you have a reference to work from, then just use standard API code to open that part and copy a parameters from this one in to that one if you wanted to.
Below is an example of copying a parameter from 'this' part into a part that is derived into 'this' one.
'Explanation: ThisDoc is a Part with another Part derived into it
'This rule will copy a UserParameter from this part, to the derived in part
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule to work. Exiting.", vbCritical, "")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oUParam As UserParameter = oPDef.Parameters.UserParameters.Item("MyTxtParam1")
Dim oDPCs As DerivedPartComponents = oPDef.ReferenceComponents.DerivedPartComponents
Dim oDP As DerivedPartComponent = oDPCs.Item(1)
Dim oDPDoc As PartDocument = oDP.ReferencedDocumentDescriptor.ReferencedDocument
Dim oDUParams As UserParameters = oDPDoc.ComponentDefinition.Parameters.UserParameters
Dim oDUParam As UserParameter = Nothing
Try
oDUParam = oDUParams.Item(oUParam.Name)
Catch
oDUParam = oDUParams.AddByValue(oUParam.Name, oUParam.Value, oUParam.Units)
End Try
And below is an example of copying a parameter from the part that is derived into 'this' part, into 'this' part.
'Explanation: ThisDoc is a Part with another Part derived into it
'This rule will copy a UserParameter from the derived in part into 'this' one
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule to work. Exiting.", vbCritical, "")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oUParams As UserParameters = oPDef.Parameters.UserParameters
Dim oDPCs As DerivedPartComponents = oPDef.ReferenceComponents.DerivedPartComponents
Dim oDP As DerivedPartComponent = oDPCs.Item(1)
Dim oDPDoc As PartDocument = oDP.ReferencedDocumentDescriptor.ReferencedDocument
Dim oDUParams As UserParameters = oDPDoc.ComponentDefinition.Parameters.UserParameters
Dim oDUParam As UserParameter = oDUParams.Item("MyTextParam1")
Dim oUParam As UserParameter = Nothing
Try
oUParam = oUParams.Item(oDUParam.Name)
Catch
oUParam = oUParams.AddByValue(oDUParam.Name, oDUParam.Value, oDUParam.Units)
End Try
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)