Using a Simple Dynamic Rule Reactor

Now suppose we want to have a “pin” (cylinder) added every time we add a link. Of course, we could have a pin+cylinder assembly, but that would not allow us to (a) have all the pins and links as siblings, and (b) delete a particular pin if we decide we don’t want it.

So we add the following method to the link design:

<%%categoryOrder ("Inventor Parameters,Inventor"), _
 %%OpenCategories ("Inventor Parameters")> _
Design link : DynamicRuleReactorExampleAdoptedComponents linkAdopt

    Method preCreateSelf() As List
        Dim result As List
        result = {{:action, :createDynamicPart, _
                   :Part, Parent, _
                   :Name, makeName(partName & "_pin"), _
                   :Design, "IvCylinder", _
                   :diameter, "linkHoleDia * 0.95", _
                   :length, "linkThickness * 2.05"} _
                 }

        Return result

    End Method

End Design

Now use Add Child again to insert another link child to test the method. Set holeDia to linkHoleDia and thickness to linkThickness in the parameters dialog.

Now the link is inserted, and a pin, too. But it looks like the pin is too long.

Since the pin is a normal Intent part, we can look at the parameters to debug the problem.

It looks like height is still the default value of 1, not a function of linkThickness. Let's look at the method again.

There it is, the cylinder doesn't have a length parameter, it is height we need to set.

Note: Another debugging trick is to simply call the event-handler method from the Immediate pane, and see what it returns. It won't actually do anything, but it will show you the "actions" that it is programmed to perform when the event really happens. Watch out for syntax errors in your generated formulas.

The existing pin “is what it is”, and so is not affected by our fix to the reactor rule. We have to create another link to do that (and first we’ll delete the existing link and pin). Note that we have to delete the link and pin independently:

Now delete the pin, too (not shown).

Test the event again by adding another link, using the same procedure we used before. This time the pin gets the correct height formula.

Using this mechanism, the user would have to manually create constraints among the pins and links, and would manually delete any extra pins.

Next: Making and Using a "Smart" Pin