Since a common scenario is to have each new link be linked to the previous one, we can implement that behavior, too. We'll start by adding a lastLink rule to the parent design:
Design Chain : DynamicRuleReactorExampleRoot IvAssemblyDocument Parameter Rule linkHoleDia As Number = 0.375 Parameter Rule linkThickness As Number = 0.250 Parameter Rule lastLink As Part = NoValue End Design
Method preCreateSelf() As List Dim result As List result = {{:action, :createDynamicPart, _ :Part, Parent, _ :Name, uniqueName("smartPin"), _ :design, "smartPin", _ :link1, (If lastLink = NoValue Then "NoValue" Else MakeString(lastLink.partName)), _ :link2, MakeString(partName), _ :onRight?, stringValue(odd?(countPartsOfType(:link)))}, _ {:action, :createDynamicRule, _ :Part, Parent, _ :Name, :lastLink, _ :formula, MakeString(partName)}_ } Return result End Method
Now as we add links, they connect automatically and alternate sides:
Note that since lastLink is a dynamic rule, it is persisted across sessions.