Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Retrieve parent component iProperties in a derived/child component

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
gharveyMHN58
597 Views, 2 Replies

Retrieve parent component iProperties in a derived/child component

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.

 

Labels (2)
2 REPLIES 2
Message 2 of 3
A.Acheson
in reply to: gharveyMHN58

The two of these sources were useful for researching this.

https://forums.autodesk.com/t5/inventor-customization/ilogic-rule-to-include-exclude-derived-paramet...

 

This one is more in depth copying all iProperties or selected iProperties,

https://forums.autodesk.com/t5/inventor-customization/derived-part-to-copy-multiple-selected-custom-...

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.

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 3
gharveyMHN58
in reply to: A.Acheson

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report