Access only filtered/visible F-curves through python in graph editor I'm looking for a way to be sure a script affect only f-curves that are showing up to the user in the graph editor (post filtering) for WYSIWYG style control.

In details:
Currently I'm getting the actions from the objects directly after checking the properties of the graph editor (check if "show_only_selected" is on for exemple) in the graph editor, then try to get related actions from selected objects.

Problem is : With the filter show_only_selected toggled On in graph editor, In the case of armature selected, if some of it's bones are unselected there are hided in editor but still affected by the script (I get all the fcurves of the actions).
Other animated properties might be affected while being invisible to the user or on the contrary being not affected while being visible.

A way to directly iterate on filtered f-curves would be really nice (if not necessary) to apply some script on what the user see/isolate.

Even more details in this blender artist thread :
context.selected_editable_fcurves

New to blender 2.79.1 is context.selected_editable_fcurves  Test script.  Prepends a toggle button to graph editor header.  Runs update code on each toggle that will print the visible fcurves to console.

Edited to include all "visible" fcurves in the graph editor.

import bpy
from bpy.props import BoolProperty

def foo(self, context):
    selected = context.selected_editable_fcurves[:]
    bpy.ops.graph.select_all_toggle(invert=True)
    others = context.selected_editable_fcurves[:]
    others.extend(selected)
    others = set(others)
    print("-" * 72)
    print("%d selected of %d visible" % (len(selected), len(others)))
    for fc in others:
        fc.select = fc in selected
        print("action:", fc.id_data.name, 
              "data_path:", fc.data_path, 
              "{%d}" % fc.array_index,
              fc.select)

    return None

bpy.types.Scene.testfc = BoolProperty(update=foo)

def testfc(self, context):
    scene = context.scene
    self.layout.prop(scene, "testfc", toggle=True)

bpy.types.GRAPH_HT_header.prepend(testfc)


Even before this context attribute became available, the same thing could be done by deselecting all fcurves (using a.fcurves.foreach_set("select", [False] * len(a.fcurves))) in all actions, then selecting all with bpy.ops.graph.select_all_toggle, those selected will be the visible ones,  and reinstating to original selection.