Using python to animate a curve FModifier I have a BezierCurve which I'm using to create a camera animation. I've set up a maximum Y Limit to stop the action of the curve on the camera and have set an Influence value of 0.7 to slow down the effect of the change (from moving along the path to stopped):



What I'd like to do is to completely stop the influence of the curve on the camera after a certain frame number. I've found I can do this by setting the Influence value to 1.0 (manually) but I need to animate this change. I can't seem to add a key frame, or a Driver on this setting so I'm trying to do it using Python.

After lots of Googling and cannibalising bits of code I've found without fully understanding it, this is the best I've been able to come up with:

import bpy

bpy.app.handlers.frame_change_pre.clear()

ob = bpy.data.curves["BezierCircle"]
 # Is there an animation?
if ob.animation_data is not None and ob.animation_data.action is not None:
    action = ob.animation_data.action


# every frame change, this function is called.
def my_handler(scene):
    frame = scene.frame_current

    if frame&lt;544:
        action.type.FModifier.influence = 0.7
    else:
        action.type.FModifier.influence = 1


bpy.app.handlers.frame_change_pre.append(my_handler)


but obviously it doesn't work, I get

AttributeError: 'Action' object has no attribute 'type'

I just can't get the right syntax to target that FModifier on my curve.

The Blender API seems to suggest that I should be able to use

bpy.types.FModifier(influence) = 0.7

or is it? 

bpy.types.FModifier.influence. = 0.7 

But then how do I target my BezierCircle ?

Any help much appreciated, I'm only slowly getting up to speed with Blender programming!



UPDATE with fixed code from answer

import bpy

bpy.app.handlers.frame_change_pre.clear()

ob = bpy.data.curves["BezierCircle"]


# debug - v2 iterates through modifiers until it find LIMITS
action = bpy.data.actions.get("BezierCircleAction")

mods = [m for f in action.fcurves if f.data_path == 'eval_time' for m in f.modifiers if m.type == 'LIMITS']

for m in mods:
    print(m.influence)

# end debug


# every frame change, this function is called.
def my_handler(scene):
    frame = scene.frame_current

    if frame&lt;544:
        ob.animation_data.action.fcurves[0].modifiers[1].influence = 0.7
    else:
        ob.animation_data.action.fcurves[0].modifiers[1].influence = 1


bpy.app.handlers.frame_change_pre.append(my_handler)
You have to specify a particular animation channel (fcurve) and a specific modifier. In this example I access the first fcurve in the fcurve list ([0]), which, because I animated the location of my object is the 'x' channel, and the first modifier ([0]) found on that fcurve: 

ob = bpy.data.objects['Cube']
ob.animation_data.action.fcurves[0].modifiers[0].influence = 0


Because you have two modifiers on your fcurve it will be modifiers[1]. 

A good way to explore the Blender Python API is to use the 'autocomplete' feature of Blender's Python console, which allows you to type part of a command, and using the autocomplete feature, view all possible sub-modules (in green):



This may not necessarily show you exactly which option you need, but will at least list the possible options, which you can further research.

Whether your current logic will do what you want, I don't know, but this does address what seemed to be the main point of your question.