I am not sure how the parent multibody technique will work with ilogic place component. So you may need to do further testing. My preference would be to keep it in the assembly as it will drive all the parts internally.
The most common way is to have the parent multibody part in the assembly. This is useful for anyone trying to figure out either by code or manually how the parts are made. However if you choose not to have it in the assembly there are a few options.
1. Know exactly the fullfilename of the Parent Part, open and adjust the parameter.
2. Loop through the assembly, look for derived parts, find it's referenced part the parent then adjust the parameter.
The code below will do this. It might fall down if you have other derived parts or the parameter is not unique but hopefully you get the idea of it's use.
Dim Length As String = InputBox("Enter Length", "Parameter InputBox", "1 in ")
For Each doc As Document In ThisDoc.Document.AllReferencedDocuments
If doc.DocumentType = kPartDocumentObject Then
Dim oDerDoc As PartDocument = doc
'Look for Derived part components
If oDerDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count < 1 Then
'MessageBox.Show("No Derived Part Components in this part", "iLogic")
ElseIf oDerDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count > 1 Then
'MessageBox.Show("More than one Derived Part Components in this part,Exiting!", "iLogic")
Else
' Set a reference to the part component definition
Dim oDerCompDef As PartComponentDefinition = oDerDoc.ComponentDefinition
'Get a reference to derived part components in this part
Dim oDerComps As DerivedPartComponents = oDerCompDef.ReferenceComponents.DerivedPartComponents
'Get a reference to derived part component
Dim oDerComp As DerivedPartComponent = oDerComps(1)'1st component
'MessageBox.Show(oDerComp.Name, "iLogic")
' Get the Reference document the parent.
Dim oRefDoc As PartDocument = oDerComp.ReferencedDocumentDescriptor.ReferencedDocument
'Change the parameter of the parent
oRefDoc.ComponentDefinition.Parameters("Length").Expression = Length
MessageBox.Show("Parameter Changed in Parent", "Success")
'Creates the iProperty in the derived part and assigns the iProperty value of the refDoc
iProperties.Value(doc.DisplayName,"Custom", "ParentPartNumber") = iProperties.Value(oRefDoc.DisplayName,"Project", "Part Number")
MessageBox.Show("iProperty Copied from Parent to Child", "Success")
End If
End If
Next
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan