Sub topic 2
What an F-curve is: one property, one curve over time
Assume you know how to insert keyframes and use the Timeline or Dope Sheet. This chapter explains the data those keyframes create and how to read it in Blender's Graph Editor.
From keyframes to an F-curve
An F-curve is a function that maps a frame number to one value of an animated property. The horizontal axis represents time, usually measured in frames. The vertical axis represents the property's value.
For example, an object's X location can be described by one F-curve:
- At frame 1, X is 0.
- At frame 24, X is 4.
- At frame 48, X is 2.
Blender evaluates the curve at every frame, including frames without keyframes. The curve's interpolation determines the values between the keys.
A keyframe is a stored value at a particular frame. The curve connects those values. A curve does not represent an entire object or even necessarily an entire property. It represents one animated value.
Property F-curves
Object location X, Y, and Z: 3 curves
Object rotation X, Y, and Z: 3 curves
Object scale X, Y, and Z: 3 curves
Material roughness 1 curveVector properties use separate curves for their components. Therefore, changing an object's location can create three F-curves, while changing a single numeric property such as visibility creates one.
Where the curve is stored
Blender organizes animation data in layers:
- An object can have animation data.
- The animation data refers to an Action, which is a collection of animation channels.
- Each channel contains an F-curve.
- Each F-curve contains keyframe points and settings such as interpolation.
A data path identifies the property being animated. For an object's location, the data path is "location". Because location is a three-component vector, the array index identifies the component:
| Data path | Array index | Value |
|---|---|---|
| `location` | 0 | X location |
| `location` | 1 | Y location |
| `location` | 2 | Z location |
The Graph Editor displays these F-curves as channels. A channel name helps you identify the property, while the curve itself contains the values over time.
Inspecting an F-curve with Python
The following script creates two location keys, finds the X-location curve, and prints its data path and number of keys. Run it with an object selected and active.
import bpy
obj = bpy.context.object
if obj is None:
raise RuntimeError("Select an object before running this script.")
obj.location = (0.0, 0.0, 0.0)
obj.keyframe_insert(data_path="location", frame=1)
obj.location = (4.0, 0.0, 0.0)
obj.keyframe_insert(data_path="location", frame=24)
action = obj.animation_data.action
fcurve = action.fcurves.find("location", index=0)
print(fcurve.data_path) # location
print(fcurve.array_index) # 0
print(len(fcurve.keyframe_points)) # 2keyframe_points contains the keys on the curve. Each point has a frame coordinate and a value coordinate. The point also stores interpolation and handle settings, which control how Blender travels between keys.
Reading the curve correctly
When a curve looks steep, the property changes quickly over a small number of frames. A flat section means the value changes slowly or stays constant. The visible shape depends on the Graph Editor's zoom, so judge the frame and value coordinates rather than the visual angle alone.
If a property has no keyframes, it has no corresponding F-curve in the Action. If you insert only a location keyframe with one component changed, Blender normally creates curves for the location components included by the keying operation.
Exercise
An object's Z location is animated from 2 at frame 10 to 8 at frame 30. What does the corresponding F-curve map, and which data path and array index identify it in Python?
Show answer
It maps frame numbers to Z-location values. Its data path is location, and its array index is 2.