Blender2.9 F-Curves Scripting Selection
Average Godot Enjoyer
I made this video because I had a lot of problems understanding how to select graph channels through script. Here are some strategies I found effective. Below is the script from the video.
import bpy
LOOK FOR FCURVE BY NAME
NAME SHOULD LOOK LIKE: 'pose.bones["C"].location'
def fcurve_by_data_path(path): #GETS ALL CURVES myFcurves = bpy.context.object.animation_data.action.fcurves
curves_array = []
counter = 0
#RETRIEVES THE CURVES WITH OUR NAME
for curve in myFcurves:
if str(curve.data_path) == path :
curves_array.append(curve)
print("DATA PATH:", curve.data_path)
print("CURVE OBJECT:", curve)
counter += 1
return curves_array
use_array = fcurve_by_data_path('pose.bones["C"].location')
THE ENTRIES IN THIS ARRAY ARE OUR CURVES
#INFLUENCE WITH SELECTION #SELECTS THE CURVES IN THE EDITOR use_array[0].select = True use_array[1].select = True use_array[2].select = True
#YOU MUST CHANGE CONTEXT BEFORE USING OPS #bpy.context.area.ui_type = 'FCURVES' #bpy.ops.graph.hide()
#INFLUENCING THEM DIRECTLY all_curves = bpy.context.object.animation_data.action.fcurves all_curves.remove(use_array[0])
bpy.context.area.ui_type = 'TEXT_EDITOR' ... https://www.youtube.com/watch?v=JFX20G-JrPg
8156030 Bytes