Match a property for some parts of an assembly

Match a property for some parts of an assembly

Miguel.CarvajalS34Q6
Advocate Advocate
528 Views
3 Replies
Message 1 of 4

Match a property for some parts of an assembly

Miguel.CarvajalS34Q6
Advocate
Advocate

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

0 Likes
Accepted solutions (2)
529 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor
Accepted solution

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

Miguel.CarvajalS34Q6
Advocate
Advocate
ok, yes copy them to the other parts.
0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor
Accepted solution

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)