Since there’s a known, logical way to constrain the pin to the two links, it would be best if these were created automatically. We can create a “smart" pin design by collecting the pin and the necessary constraints in a component group. Start by creating a new design that mixes in IvComponentGroup:
Add the following parameter rules to the design:
Design SmartPin : DynamicRuleReactorExampleRoot IvComponentGroup
' the first link part to constrain to the pin
Parameter Rule link1 As Part = NoValue
' the second link part to constrain to the pin
Parameter Rule link2 As Part = NoValue
' controls the positioning of the pin relative to the links
Parameter Rule onRight? As Boolean = True
Now add the child rules for the pin and four constraints:
Child pin As :IvCylinder
diameter = linkHoleDia * 0.95
height = linkThickness * 2.05
End Child
Child link1Face As :IvMateConstraint
part1 = link1
part2 = pin
entity1 = (If onRight? Then "leftFace" Else "rightFace")
entity2 = "fBottom"
solution = :Flush
offset = 0
End Child
Child link2Face As :IvMateConstraint
part1 = link2
part2 = pin
entity1 = (If onRight? Then "rightFace" Else "leftFace")
entity2 = "fTop"
solution = :Flush
offset = 0
End Child
Child link1Axis As :IvMateConstraint
part1 = link1
part2 = pin
entity1 = "hole1Axis"
entity2 = "fMain"
inferredType2 = :InferredLine
End Child
Child link2Axis As :IvMateConstraint
part1 = link2
part2 = pin
entity1 = "hole2Axis"
entity2 = "fMain"
inferredType2 = :InferredLine
End Child
Finally, redefine the displayName rule so we can tell which pin is which.
Rule displayName As String
' construct a displayName string in the pattern:
' partName (link1 : link2)
Dim result As String = partName
result = result & " ("
If link1 = NoValue Then
result = result & "?"
Else
result = result & link1.partName
End If
result = result & " : "
If link2 = NoValue Then
result = result & "?"
Else
result = result & link2.partName
End If
result = result & ")"
Return result
End Rule
Time to test the smart pin. Delete the pins and all but the first two links.
Now add a SmartPin child, selecting link_1 and link_2 in the Part Editor
Notice the SmartPin in the browser with the custom display name.
Using a smart pin like this means that we have a higher-level functional model. You’re no longer dealing with an occurrence and a handful of constraints; you’re dealing with a pin. And the “pin” knows all the “pin-like” behavior it needs. You can no longer delete individual pin-related constraints; instead you have to delete the entire pin, automatically including all of its constraints (or similar behavior).
<%%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, uniqueName("smartPin"), _
:design, "smartPin", _
:link1, "NoValue", _
:link2, MakeString(partName)}}
Return result
End Method
End Design
Now when we add a dynamic link, it automatically gets a pin attached to it. We can then manually connect the pin to the previous link.