I'm writing a script for Blender that needs to be run from the terminal. I would like to change the interpolation type of f-curves in my script. When using Blender's normal UI, the sequence of commands for what I want to accomplish is:

bpy.context.area.ui_type = 'FCURVES'

This works great when I run the code within Blender, however when I try to execute this from the terminal, I receive the following error:

bpy.context.area.ui_type = 'FCURVES'
AttributeError: 'NoneType' object has no attribute 'ui_type'

This is understandable, because in headless mode, apparently there is no area or UI. How can I achieve the same results in headless mode?



1 Answer 1


No UI in headless mode.

There are a number of similar questions.

Change extrapolation type from Python running in the background

Look for lower level API calls. In the UI the interpolation is set from the Keys Menu indicating that it is a property of an fcurve's keyframe point.

>>> action = D.actions['CubeAction']
>>> fcurve = action.fcurves[0]
>>> fcurve.keyframe_points[0].interpolation

>>> fcurve.keyframe_points[0].interpolation = 'BACK'

Consult the docs on bpy.types.Keyframe for options, or to get valid enums from error message feedback

>>> fcurve.keyframe_points[0].interpolation = 'FOO'
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
TypeError: bpy_struct: item.attr = val: enum "FOO" not found in ('CONSTANT', 'LINEAR', 'BEZIER', 'SINE', 'QUAD', 'CUBIC', 'QUART', 'QUINT', 'EXPO', 'CIRC', 'BACK', 'BOUNCE', 'ELASTIC')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .