Part of a script from “Rob in Motion”
import bpy
import csv
import numpy as np
data_path = 'C:/Users/E/Desktop/example.csv'
ob = bpy.context.object
with open(data_path, 'r') as f:
reader = csv.reader(f, delimiter=',')
names = next(reader)
data = np.array(list(reader))
shapekeys = ob.data.shape_keys.key_blocks
for i in range(data.shape[0]):
if data[i][1] != '0':
for shape in shapekeys:
if shape.name in names:
index = names.index(shape.name)
shape.value=float(data[i][index])
shape.keyframe_insert("value", frame=i)
This is a script to get face tracking data from a saved file and make keyframes for Shape Keys. I wish instead to have that data affect bones Y translate values.
To minimize the complexity I have all the bones in the Armature given the same name as the shape key names.
My goal is to have the data placed into Y bone locations in my control panel and they would drive my shape keys. That way I could fine tune or add manually to the existing animation data directly from the control panel.