Hello,
I am trying to retrieve the part number of the parent component in a derived child component through ilogic, and then pass this to a custom iproperty in the child component.
The parent is the raw material, which is then machined to produce the child. I would like to be able to pull in the part number of the parent to then populate a field in the drawing of the machined part.
Any help is greatly appreciated.
Using Inventor 2022.
Solved! Go to Solution.
Solved by A.Acheson. Go to Solution.
The two of these sources were useful for researching this.
This one is more in depth copying all iProperties or selected iProperties,
However the selected iProperties failed to run for me so I created the below to just target the iProperty you requested.
If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then MessageBox.Show("Make a Part Document the active document,Exiting", "iLogic") Else Dim oDerDoc As PartDocument oDerDoc = ThisApplication.ActiveDocument '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 oDerCompDef = oDerDoc.ComponentDefinition 'Get a reference to derived part components in this part Dim oDerComps As DerivedPartComponents oDerComps = oDerCompDef.ReferenceComponents.DerivedPartComponents 'Get a reference to derived part component Dim oDerComp As DerivedPartComponent oDerComp = oDerComps(1)'1st component 'MessageBox.Show(oDerComp.Name, "iLogic") ' Get the Reference document. Dim oRefDoc As Document oRefDoc = oDerComp.ReferencedDocumentDescriptor.ReferencedDocument
'Creates the iProperty in the derived part and assigns the iProperty value of the refDoc iProperties.Value("Custom", "ParentPartNumber") = iProperties.Value(oRefDoc.DisplayName,"Project", "Part Number") MessageBox.Show("iProperty Copied from Parent to Child", "Success") End If End If
I hope that helps.
Thank you, that's perfect, does exactly what I was looking for.
Thank you again.
Can't find what you're looking for? Ask the community or share your knowledge.