Usually, you will make connections using Animation objects. Animation objects perform the data conversion between data source and connected object. The figure below illustrates the concept of Animation connections.
Animation Connections Example
To make a linear animation connection using the Animations dialog box:
- Double-click a rectangle. The Animations dialog box appears.
- Select the Size tab and click the Height button. The Animations dialog box expands.
- Enter a data source to animate the rectangle's height.
- From the Data Conversion list box, select Range. This will allow the rectangle's height to change within a specific range based on the value of the data source.
- Click OK. Note that the rectangle now has a linear animation object associated with it that transforms the data source value to scale the rectangle's height.
Making an Animation Connection through a Script
The following script uses the Linear Animation object to form the connection from a rectangle's Vertical Position property to a data source. This script is entered in the Click event of a toolbar named btnDirectConn. In this example, Animations is the picture name. For more information on the methods and properties used in the script, namely SetSource, Connect, DoesPropertyHaveTargets, and GetPropertyTargets, see the iFIX Automation Interfaces Electronic Book.
Example: Building an Animation Connection through a Script
Private Sub btnDirectConn_Click()
Dim iRect As Object
Dim iOval As Object
Dim LinearObject As Object
Dim strFullname As String
Dim blnHasTargets As Boolean
Dim lngStatus As Long
Dim lngNumTargets As Long
Dim lngIndex As Long
Dim strPropertyName As String
Dim strSource As String
Dim vtTargets()
'Create a rectangle and an oval
Set iRect = Animations.BuildObject("rect")
Set iOval = Animations.BuildObject("oval")
'Set some positioning and size attributes on
'the rectangle
iRect.HorizontalPosition = 80
iRect.VerticalPosition = 45
iRect.Height = 5
iRect.Width = 10
iOval.HorizontalPosition = 60
iOval.VerticalPosition = 35
iOval.Height = 5
iOval.Width = 10
iRect.Commit
iOval.Commit
'Create a Linear animation object for the rectangle
Set LinearObject = iRect.BuildObject("linear")
'Set the source of the Linear animation object
LinearObject.SetSource "AI1.F_CV", True
'Specify the Linear animation object's minimum and
'maximum Input and Output values
LinearObject.LoInValue = 0
LinearObject.LoOutValue = 0
LinearObject.HiInValue = 100
LinearObject.HiOutValue = 50
'Set UseDelta to True to ensure that the base position
'of the object will be added to the output value when
'the Linear object evaluates. If UseDelta is set to
'False, the output value would be absolute when the
'Linear object evaluates
LinearObject.UseDelta = True
'Connect the rectangle's VerticalPosition property to
'the output value of the Linear animation object
strFullname = LinearObject.FullyQualifiedName & _
".OutputValue"
iRect.Connect "VerticalPosition", strFullname, lngStatus
'Create a string containing the fully qualified data
'source for the rectangle's VerticalPosition property
strSource = "Animations." + iRect.Name + _
".VerticalPosition"
'Connect the oval's HorizontalFillPercentage property
'to the rectangle's VerticalPosition property by using
'the string created above as a data source
iOval.Connect "HorizontalFillPercentage", strSource, _
lngStatus
'Once connected, you can verify that the Rectangle's
'Vertical Position is being used as a data source for the
'Oval's Horizontal Fill Percentage using the Target methods.
'Now that there is a direct connection to the rectangle's
'VerticalPosition property, retrieve information about
'the objects that are using the VerticalPosition property
'as a data source. This call will return if the property
'is being used as a data source, how many objects are
'using it as a data source, the status of the objects,
'and the index of the object be passed to the
'GetPropertyTargets method.
'NOTE: If you only want to determine the number of
'objects using the property as a data source, you can use
'the NumberOfTargets property instead.
iRect.DoesPropertyHaveTargets "VerticalPosition", _
blnHasTargets, lngNumTargets, lngStatus, lngIndex
'Use the lngIndex value from the DoesPropertyHaveTargets
'call to determine which property of the rectangle has
'targets and to obtain a list of object names that have
'built connections to this property.
iRect.GetPropertyTargets lngIndex, strPropertyName, _
vtTargets
End Sub