< Previous | Contents | Next >
Animation
To animate an Input via script, the first step is to add a BezierSpline. A Bezier Spline is an animation curve that can be viewed in the spline editor. It is a storehouse for the information contained in the animated properties of a tool. To do this for a Merge’s blend property, the following code could be employed:
Merge1.Blend = BezierSpline({})
By setting the input’s value at a specific time, keyframes will be created.
![]()
If the property is a Point DataType, use the Path{} function instead to add a bezier-based path.
If the desire was to then animate the blend from 1 to 0 over the period of 100 frames, one could use the following code:
Merge1.Blend[1] = 1
Merge1.Blend[100] = 0
spline = splineout:GetTool()
if splineout then
-- then uses GetTool() to get the Bezier Spline modifier itself, and
splineout = Merge1.Blend:GetConnectedOutput()
-- gets the spline output that is connected to the Blend input,
You can request a collection of all keyframes on a BezierSpline:
local spline, splineout, splinedata
end
dump(splinedata)
-- data is then dumped.
splinedata = spline:GetKeyFrames()
-- then uses GetKeyFrames() to get a table of a spline data. This
The data returned consists of a nested table, one for each keyframe and with a key value of the keyframe’s time. The subtables contain an entry for the keyframe’s value, and optionally, subtables for the left and/or right handles, called “LH” and “RH.” The handle subtables contain two entries, for the handle’s X & Y position.
To remove key frames from an animated spline, set the value to nil.
Merge1.Blend[composition.CurrentTime] = nil
In the above case, the key frame was removed from the comp’s current frame. However, if that key frame was the only point on an animation spline, the point would not be deleted, as splines must have at least one point at all times.
Merge1.Blend = nil
The animation can be deleted completely, reverting the Input to a static value. Instead of specifying the time set the whole Input to nil.