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
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Solved by WCrihfield. Go to 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
(Not an Autodesk Employee)
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
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.