# Fcurve noise modifier: change settings with python

I have a noise modifier on a scaling action on a cube. I want to adjust the scale, strength and phase settings of the modifier, for all three axes of the action, with python.

bpy.ops.anim.keyframe_insert_menu(type='Scaling')
bpy.context.area.type = 'GRAPH_EDITOR'


but I can't figure out how to access the modifier settings for scale, strength and phase.

• Please mark the answer as accepted, click on the check mark beside the answer to toggle it from hollow to green. I removed [solved] from the title. – stacker Feb 3 '15 at 8:10

You shouldn't ever use bpy.ops.anim.keyframe_insert_menu(), it's solely meant for user interface interaction. Use Object.keyframe_insert() (not the operator!) instead.

There's also no reason to use bpy.ops.graph.fmodifier_add(), especially because the dependency on an area type. Use the low-level RNA methods instead:

import bpy

ob = bpy.context.object

ob.keyframe_insert("scale") # ensures animation_data and action are not None
action = ob.animation_data.action

for fcu in action.fcurves:
if fcu.data_path == "scale":
mod = fcu.modifiers.new("NOISE")
mod.scale = 5