Timecode,BlendShapeCount,eyeBlinkRight,eyeLookDownRight,eyeLookInRight,eyeLookOutRight,eyeLookUpRight,eyeSquintRight,eyeWideRight,eyeBlinkLeft,eyeLookDownLeft,eyeLookInLeft,eyeLookOutLeft,eyeLookUpLeft,eyeSquintLeft,eyeWideLeft,jawForward,jawRight,jawLeft,jawOpen,mouthClose,mouthFunnel,mouthPucker,mouthRight,mouthLeft,mouthSmileRight,mouthSmileLeft,mouthFrownRight,mouthFrownLeft,mouthDimpleRight,mouthDimpleLeft,mouthStretchRight,mouthStretchLeft,mouthRollLower,mouthRollUpper,mouthShrugLower,mouthShrugUpper,mouthPressRight,mouthPressLeft,mouthLowerDownRight,mouthLowerDownLeft,mouthUpperUpRight,mouthUpperUpLeft,browDownRight,browDownLeft,browInnerUp,browOuterUpRight,browOuterUpLeft,cheekPuff,cheekSquintRight,cheekSquintLeft,noseSneerRight,noseSneerLeft,tongueOut,HeadYaw,HeadPitch,HeadRoll,LeftEyeYaw,LeftEyePitch,LeftEyeRoll,RightEyeYaw,RightEyePitch,RightEyeRoll
62:53:12:37.006,61,0.0038254452,0.0000000000,0.1141537726,0.0000000000,0.1121030822,0.7145567536,0.1047579870,0.0040954584,0.0000000000,0.0000000000,0.0076493639,0.1129931882,0.7144263983,0.1038799658,0.0218451358,0.0054703844,0.0003128086,0.0232388079,0.0352823287,0.1415321976,0.2783249319,0.0000009201,0.0094441799,0.0000197465,0.0060852813,0.0994004756,0.0328713655,0.0448998362,0.0461372286,0.2140853554,0.2000554800,0.1428411156,0.0647139996,0.1136871427,0.0496682189,0.0229504481,0.0210860930,0.0806388408,0.0848821178,0.0140275164,0.0170790628,0.1062886938,0.1063234955,0.1304191500,0.0000075585,0.0000081810,0.1296568215,0.0553273745,0.0569460094,0.1230981424,0.1301469654,0.0002140299,0.0339467451,-0.2846423984,0.0579877235,0.0000000000,0.0000000000,0.0000000000,0.0000000000,0.0000000000,0.0000000000
62:53:12:38.006,61,0.0045552836,0.0000000000,0.1147334576,0.0000000000,0.1261096150,0.7352762222,0.1135740876,0.0048771584,0.0000000000,0.0000000000,0.0081078131,0.1270415187,0.7351591587,0.1130069345,0.0223178510,0.0057966919,0.0002878802,0.0236664098,0.0373653620,0.1862419248,0.3506298959,0.0000008468,0.0093634762,0.0000181728,0.0056017591,0.0954650491,0.0359293073,0.0449097492,0.0460928008,0.2342759967,0.2170172632,0.1566291451,0.0659807324,0.1184609458,0.0505686179,0.0233521722,0.0214929860,0.0817659423,0.0867322832,0.0141550489,0.0172717925,0.1280132830,0.1278558224,0.1301664412,0.0000069562,0.0000075291,0.1588735580,0.0572018251,0.0580299273,0.1253345162,0.1342534274,0.0002906183,0.0339467451,-0.2846423984,0.0579877235,0.0000000000,0.0000000000,0.0000000000,0.0000000000,0.0000000000,0.0000000000
The data (above) the first row is used as the list of shape keys affected or in my case bones names affected. In this sample it’s just frame 1 and 2. The time stamp, number of shape keys, the values to all the shape keys separated by “,” in order of the first row.
Below is the script provided to read the data and apply to the shape keys.
I figured that I can just select the Armature and use a simple assign but the next problem there are no shape keys to count when you select the armature.
The line: shapekeys = ob.data.shape_keys.key_blocks will not work unless what is selected is the mesh. And I don’t know how an for/in command works or a if/in works. Everything from the comment is my addition that doesn’t work.
import bpy
import csv
import numpy as np
data_path = 'C:/Users/E/Desktop/example.csv'
ob = bpy.context.object
context = bpy.context
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])
#get this data locY = shape.value
#get this data boneName = shape.name
#get the current frame with variable i
bpy.context.selected_objects
pb = ob.pose.bones.get(boneName)
pb.location.y = locY /10
pb.keyframe_insert("location",index=1,frame= i)