Extending the Dynamic Rule Reactor

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
Next we'll change the reactor rule in the link design to:
  1. set link1 to the last link, if there is one
  2. set onRight? correctly so that the links alternate
  3. add a second action to update the lastLink rule
    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.