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: 

Match a property for some parts of an assembly

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Miguel.CarvajalS34Q6
225 Views, 3 Replies

Match a property for some parts of an assembly

greetings to all.

I have a need, I want each piece of an assembly to inherit a property of the assembly, but I can choose which one inherits the property and which does not. It is possible to generate a code that helps me with this task.
thanks for your help

Labels (5)
3 REPLIES 3
Message 2 of 4

Hi @Miguel.CarvajalS34Q6.  Not sure what you mean by inherit, but we can definitely copy iProperties or iProperty values from one document to others.  I do not think there is a way to 'Link' them though.  What about if you were to select the assembly components you want to copy the property to, before the rule starts, then run the rule, then the rule will iterate through those components, copying the assembly property to each of them.  And if needed, you could create another similar rule that could work the opposite way...choose components before starting the rule to remove the property from, then run the rule to remove the property from them.  Does that sound like a process that would work OK for you?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 4

ok, yes copy them to the other parts.
Message 4 of 4

Here is an example of an iLogic rule for a task like that.  You will need to edit/change which iProperty you want to copy on Lines 7 and 12 though.

Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Return
	Dim oADoc As AssemblyDocument = ThisDoc.Document
	Dim oSS As Inventor.SelectSet = oADoc.SelectSet
	If oSS.Count = 0 Then Return
	'<<< EDIT THIS >>>
	Dim oValue As Object = iProperties.Value("Custom", "PropertyToCopy")
	For Each oObj In oSS
		If TypeOf oObj Is ComponentOccurrence Then
			Dim oOcc As ComponentOccurrence = oObj
			'<<< EDIT THIS >>>
			iProperties.Value(oOcc.Name, "Custom", "PropertyToCopy") = oValue
		End If
	Next
	If oADoc.RequiresUpdate Then oADoc.Update2(True)
	If oADoc.Dirty Then oADoc.Save2(True)
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

EESignature

(Not an Autodesk Employee)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report