Copying and Pasting Fcurve modifiers Through Python I posted this on blenderartist.org, but to no avail.

I want to be able copy the Fcurve modifiers applied to ShapeKey drivers and paste them onto their counterparts on other objects, the other object's ShapeKey drivers.

This is manually quite simple to do; as in, you just copy the all the fcurve modifiers on a Driver from the graph editor, select the other object and again in the graph editor paste them whichever fcurve you want, in this case, its drivers... But with scripting in Blender, it turns out to be an enigma, whereas there is only the ability to add and remove an fmodifier to an fcurve, example:

bpy.data.shape_keys['Key'].animation_data.drivers[0].modifiers.new()
bpy.data.shape_keys['Key'].animation_data.drivers[0].modifiers.remove()


But bpy.ops.graph.fmodifier_copy() seems unbelievably tricky and seems not to play well within a script, like I think you need the area type to graph editor and invoke the command, which sounds pretty redundant.

And since the Blender API is almost totally devoid of real-world examples explaining the application of its commands and procedures, I'm totally stuck. I searched far and wide, even tried digging through other scripts.

How can I accomplish this task?
I don't think it is possible to get/set the active fcurve / driver. So you can not override the context for bpy.ops.graph.fmodifier_copy

You might use from_existing and adjust the data_path attribute from the returned driver accordingly if you want to copy the driver or try out this script:

import bpy

sk = bpy.data.shape_keys['Key']

source = sk.animation_data.drivers[0]
target = sk.animation_data.drivers[1]

for mod in source.modifiers:
    copy = target.modifiers.new(mod.type)
    for prop in mod.bl_rna.properties:
        if not prop.is_readonly:
            setattr(copy, prop.identifier, getattr(mod, prop.identifier))