There are cases, especially when importing from third-party packages, where animation curves in Blender become literally cluttered with numerous control points, most of which have little effect on the overall shape of the curve. Many points on a curve increases the complexity of the scene and complicates animation calculations. However, the number of points on animation curves can be easily reduced if necessary.
We can manually reduce the number of points on an animation curve.
To do this, select the desired animation curve in the Graph Editor area and press in the menu:
Key – Density – Decimate (Ratio)
Then, drag the mouse to select an acceptable ratio, from 0.0 (no points will be deleted) to 1.0 (all points except the two outermost ones will be deleted). The number of points will be uniformly reduced according to the selected value.
The same can be done using the Blender Python API.
The
|
1 |
bpy.ops.graph.decimate(mode, factor) |
operator is responsible for decreasing the number of points on animation curves.
As an example, let’s decrease the number of points on the animation curve for moving a default cube along the X axis.
The graph.decimate() operator is context-sensitive. This means that to call it from the Text Editor area, we must temporarily override the context.
The pointer to the Graph Editor area:
|
1 2 3 |
area = next((area for area in bpy.context.screen.areas if area.type == 'GRAPH_EDITOR')) # <bpy_struct, Area at 0x0000020BFBFA1FC0> |
Having it we can override the context using temp_override() to call the desired graph.decimate() operator:
|
1 2 3 4 5 |
with bpy.context.temp_override(area=area): bpy.ops.graph.decimate( mode='RATIO', factor=0.7 ) |
In the graph.decimate() operator parameters, we specify the “RATIO” mode — the percentage of the number of points to the total length of the curve, and a factor of 0.7 — which is exactly the value we selected earlier with the mouse. That is, with a factor of 0.0, the curve will not be simplified at all, and with a factor of 1.0, all points except the outermost ones will be removed. The value of 0.7 we used is optimal in our case, achieving simplification without significantly distorting the animation curve.
After executing the code, the number of points on the cube’s X-axis animation curve will be reduced.

.blend file on Patreon