import csv
import sys
import maya.cmds
path = "D:\\workspace\\td\\cpp_csv\\data\\in.csv"
file = open(path)
reader = csv.reader(file)
header = next(reader) #The first line
data = [row for row in reader]
# def rename_morph_targets( node_name, attr_dict, quiet = False ):
# # list to catch our failures
# fail_list = [ ]
# # How many targets there are in the alias list
# number_of_targets = maya.cmds.getAttr( '{0}.weight'.format( node_name ), size = True )
# # Iterate through the weight list
# for index in range( 0, number_of_targets ):
# # Query the name of the current blendshape weight
# old_name = maya.cmds.aliasAttr( '{0}.weight[{1}]'.format( node_name, index ), query = True )
# # If the old name isn't in the attr_dict, we're going to pass on it.
# if old_name in attr_dict.keys( ):
# # We're going to rename
# new_name = attr_dict[ old_name ]
# print 'Found old name: ', index, new_name, old_name
# absolute_name = '{0}.weight[{1}]'.format( node_name, index )
# maya.cmds.aliasAttr( new_name, absolute_name ) # Re-aliasing / Renaming occurs here.
# if not quiet:
# print 'Changed {0} -> {1}'.format( old_name, new_name )
# # Add the failure to the fail list
# else:
# fail_list.append( old_name )
# if fail_list:
# maya.cmds.warning( '{0} names were not changed. Check console for details'.format( len( fail_list ) ) )
# for name in fail_list:
# print name
# # example test
# # renaming function goes here to rename the one column to the other column
# print(header)
# print(data[0])
import maya.cmds as cmds
def setKeyframes():
global data
obj = cmds.ls(selection=True)[0]
for d in data:
if len(d) < 3: continue
print(d[2])
EyeBlinkLeft = float(d[2]*2-1)
cmds.setKeyframe(obj + '.translateY', value=EyeBlinkLeft, time=d[0])
setKeyframes()
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme